fix configs

This commit is contained in:
Livio Amstutz 2020-03-25 11:17:38 +01:00
parent 8b23c491f9
commit 40734f27c7
9 changed files with 38 additions and 58 deletions

View File

@ -2,6 +2,7 @@ package api
import ( import (
"context" "context"
grpc_util "github.com/caos/zitadel/internal/api/grpc"
"github.com/caos/zitadel/internal/api/grpc/server" "github.com/caos/zitadel/internal/api/grpc/server"
"github.com/caos/zitadel/pkg/admin/api/grpc" "github.com/caos/zitadel/pkg/admin/api/grpc"
) )
@ -12,14 +13,13 @@ type API struct {
} }
type Config struct { type Config struct {
GRPCServer grpc.Config GRPC grpc_util.Config
Gateway grpc.GatewayConfig
} }
func Start(ctx context.Context, conf *Config) error { func Start(ctx context.Context, conf *Config) error {
api := &API{ api := &API{
grpcServer: *grpc.StartServer(conf.GRPCServer), grpcServer: *grpc.StartServer(conf.GRPC.ToServerConfig()),
gateway: *grpc.StartGateway(conf.Gateway), gateway: *grpc.StartGateway(conf.GRPC.ToGatewayConfig()),
} }
server.StartServer(ctx, &api.grpcServer) server.StartServer(ctx, &api.grpcServer)
server.StartGateway(ctx, &api.gateway) server.StartGateway(ctx, &api.gateway)

View File

@ -1,24 +1,19 @@
package grpc package grpc
import ( import (
grpc_util "github.com/caos/zitadel/internal/api/grpc"
"github.com/caos/zitadel/internal/api/grpc/server" "github.com/caos/zitadel/internal/api/grpc/server"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"strings" "strings"
) )
type GatewayConfig struct {
Port string
GRPCEndpoint string
CustomHeaders []string
}
type Gateway struct { type Gateway struct {
grpcEndpoint string grpcEndpoint string
port string port string
cutomHeaders []string cutomHeaders []string
} }
func StartGateway(conf GatewayConfig) *Gateway { func StartGateway(conf *grpc_util.GatewayConfig) *Gateway {
return &Gateway{ return &Gateway{
grpcEndpoint: conf.GRPCEndpoint, grpcEndpoint: conf.GRPCEndpoint,
port: conf.Port, port: conf.Port,

View File

@ -1,9 +1,11 @@
package grpc package grpc
import ( import (
"github.com/caos/zitadel/internal/api/grpc/server/middleware"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
"google.golang.org/grpc" "google.golang.org/grpc"
grpc_util "github.com/caos/zitadel/internal/api/grpc"
"github.com/caos/zitadel/internal/api/grpc/server/middleware"
) )
var _ AdminServiceServer = (*Server)(nil) var _ AdminServiceServer = (*Server)(nil)
@ -18,10 +20,9 @@ type Server struct {
searchLimit int searchLimit int
} }
func StartServer(conf Config) *Server { func StartServer(conf *grpc_util.ServerConfig) *Server {
return &Server{ return &Server{
port: conf.Port, port: conf.Port,
searchLimit: conf.SearchLimit,
} }
} }

View File

@ -2,6 +2,8 @@ package api
import ( import (
"context" "context"
grpc_util "github.com/caos/zitadel/internal/api/grpc"
"github.com/caos/zitadel/internal/api/grpc/server" "github.com/caos/zitadel/internal/api/grpc/server"
"github.com/caos/zitadel/pkg/auth/api/grpc" "github.com/caos/zitadel/pkg/auth/api/grpc"
) )
@ -12,14 +14,13 @@ type API struct {
} }
type Config struct { type Config struct {
GRPCServer grpc.Config GRPC grpc_util.Config
Gateway grpc.GatewayConfig
} }
func Start(ctx context.Context, conf *Config) error { func Start(ctx context.Context, conf *Config) error {
api := &API{ api := &API{
grpcServer: *grpc.StartServer(conf.GRPCServer), grpcServer: *grpc.StartServer(conf.GRPC.ToServerConfig()),
gateway: *grpc.StartGateway(conf.Gateway), gateway: *grpc.StartGateway(conf.GRPC.ToGatewayConfig()),
} }
server.StartServer(ctx, &api.grpcServer) server.StartServer(ctx, &api.grpcServer)
server.StartGateway(ctx, &api.gateway) server.StartGateway(ctx, &api.gateway)

View File

@ -1,16 +1,13 @@
package grpc package grpc
import ( import (
"github.com/caos/zitadel/internal/api/grpc/server"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"strings" "strings"
)
type GatewayConfig struct { "github.com/grpc-ecosystem/grpc-gateway/runtime"
Port string
GRPCEndpoint string grpc_util "github.com/caos/zitadel/internal/api/grpc"
CustomHeaders []string "github.com/caos/zitadel/internal/api/grpc/server"
} )
type Gateway struct { type Gateway struct {
grpcEndpoint string grpcEndpoint string
@ -18,7 +15,7 @@ type Gateway struct {
cutomHeaders []string cutomHeaders []string
} }
func StartGateway(conf GatewayConfig) *Gateway { func StartGateway(conf *grpc_util.GatewayConfig) *Gateway {
return &Gateway{ return &Gateway{
grpcEndpoint: conf.GRPCEndpoint, grpcEndpoint: conf.GRPCEndpoint,
port: conf.Port, port: conf.Port,

View File

@ -1,27 +1,23 @@
package grpc package grpc
import ( import (
"github.com/caos/zitadel/internal/api/grpc/server/middleware"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
"google.golang.org/grpc" "google.golang.org/grpc"
grpc_util "github.com/caos/zitadel/internal/api/grpc"
"github.com/caos/zitadel/internal/api/grpc/server/middleware"
) )
var _ AuthServiceServer = (*Server)(nil) var _ AuthServiceServer = (*Server)(nil)
type Config struct {
Port string
SearchLimit int
}
type Server struct { type Server struct {
port string port string
searchLimit int searchLimit int
} }
func StartServer(conf Config) *Server { func StartServer(conf *grpc_util.ServerConfig) *Server {
return &Server{ return &Server{
port: conf.Port, port: conf.Port,
searchLimit: conf.SearchLimit,
} }
} }

View File

@ -2,6 +2,8 @@ package api
import ( import (
"context" "context"
grpc_util "github.com/caos/zitadel/internal/api/grpc"
"github.com/caos/zitadel/internal/api/grpc/server" "github.com/caos/zitadel/internal/api/grpc/server"
"github.com/caos/zitadel/pkg/management/api/grpc" "github.com/caos/zitadel/pkg/management/api/grpc"
) )
@ -12,14 +14,13 @@ type API struct {
} }
type Config struct { type Config struct {
GRPCServer grpc.Config GRPC grpc_util.Config
Gateway grpc.GatewayConfig
} }
func Start(ctx context.Context, conf *Config) error { func Start(ctx context.Context, conf *Config) error {
api := &API{ api := &API{
grpcServer: *grpc.StartServer(conf.GRPCServer), grpcServer: *grpc.StartServer(conf.GRPC.ToServerConfig()),
gateway: *grpc.StartGateway(conf.Gateway), gateway: *grpc.StartGateway(conf.GRPC.ToGatewayConfig()),
} }
server.StartServer(ctx, &api.grpcServer) server.StartServer(ctx, &api.grpcServer)
server.StartGateway(ctx, &api.gateway) server.StartGateway(ctx, &api.gateway)

View File

@ -1,24 +1,19 @@
package grpc package grpc
import ( import (
grpc_util "github.com/caos/zitadel/internal/api/grpc"
"github.com/caos/zitadel/internal/api/grpc/server" "github.com/caos/zitadel/internal/api/grpc/server"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"strings" "strings"
) )
type GatewayConfig struct {
Port string
GRPCEndpoint string
CustomHeaders []string
}
type Gateway struct { type Gateway struct {
grpcEndpoint string grpcEndpoint string
port string port string
cutomHeaders []string cutomHeaders []string
} }
func StartGateway(conf GatewayConfig) *Gateway { func StartGateway(conf *grpc_util.GatewayConfig) *Gateway {
return &Gateway{ return &Gateway{
grpcEndpoint: conf.GRPCEndpoint, grpcEndpoint: conf.GRPCEndpoint,
port: conf.Port, port: conf.Port,

View File

@ -1,6 +1,7 @@
package grpc package grpc
import ( import (
grpc_util "github.com/caos/zitadel/internal/api/grpc"
"github.com/caos/zitadel/internal/api/grpc/server/middleware" "github.com/caos/zitadel/internal/api/grpc/server/middleware"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
"google.golang.org/grpc" "google.golang.org/grpc"
@ -8,20 +9,13 @@ import (
var _ ManagementServiceServer = (*Server)(nil) var _ ManagementServiceServer = (*Server)(nil)
type Config struct {
Port string
SearchLimit int
}
type Server struct { type Server struct {
port string port string
searchLimit int
} }
func StartServer(conf Config) *Server { func StartServer(conf *grpc_util.ServerConfig) *Server {
return &Server{ return &Server{
port: conf.Port, port: conf.Port,
searchLimit: conf.SearchLimit,
} }
} }