Documentation
¶
Index ¶
- func AddServiceDiscoveryCallback(serviceName string, callback CallbackFunc)
- func GetServiceDiscoveryMapper() map[string]CallbackFunc
- func SocketDial(ctx context.Context, socket string, additionalOpts ...grpc.DialOption) (*grpc.ClientConn, error)
- func TestServerFor[TServer any, TClient any](registersvc func(grpc.ServiceRegistrar, TServer), ...) func(svc TServer) (client TClient, cleanup func(), err error)
- func TestSocketServerFor[TServer any, TClient any](registersvc func(grpc.ServiceRegistrar, TServer), ...) func(svc TServer) (client TClient, cleanup func(), err error)
- func ToProtoComponentRef(config *ref.ComponentRefConfig) *pb.ComponentRefConfig
- func ToProtoConfig(config ref.Config) *pb.Config
- func ToProtoSecretRef(secrets []*ref.SecretRefConfig) []*pb.SecretRefConfig
- type CallbackFunc
- type Component
- type GRPCConnectionDialer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddServiceDiscoveryCallback ¶
func AddServiceDiscoveryCallback(serviceName string, callback CallbackFunc)
AddServiceDiscoveryCallback register callback function, not concurrent secure
func GetServiceDiscoveryMapper ¶
func GetServiceDiscoveryMapper() map[string]CallbackFunc
func SocketDial ¶
func SocketDial(ctx context.Context, socket string, additionalOpts ...grpc.DialOption) (*grpc.ClientConn, error)
SocketDial creates a grpc connection using the given socket.
func TestServerFor ¶
func TestServerFor[TServer any, TClient any](registersvc func(grpc.ServiceRegistrar, TServer), clientFactory func(grpc.ClientConnInterface) TClient) func(svc TServer) (client TClient, cleanup func(), err error)
TestServerFor returns a grpcServer factory that bootstraps a grpcserver backed by a buf connection (in memory), and returns the given clientFactory instance to communicate with it. it also provides cleanup function for close the grpcserver and client connection.
usage, serverFactory := TestServerFor(proto.RegisterMyService, proto.NewMyServiceClient) client, cleanup, err := serverFactory(&your_service{}) require.NoError(t, err) defer cleanup()
func TestSocketServerFor ¶
func TestSocketServerFor[TServer any, TClient any](registersvc func(grpc.ServiceRegistrar, TServer), clientFactory func(GRPCConnectionDialer) TClient) func(svc TServer) (client TClient, cleanup func(), err error)
TestSocketServerFor returns a grpcServer factory that bootstraps a grpcserver backed by grpc socket, and returns the given clientFactory instance to communicate with it. it also provides cleanup function for close the grpcserver and client connection. The closure of dial needs to be handled by the user themselves
usage, serverFactory := TestSocketServerFor(proto.RegisterMyService, NewGRPCHello) // (func NewGRPCHello(dialer pluggable.GRPCConnectionDialer) *grpcHello) client, cleanup, err := serverFactory(&your_service{}) require.NoError(t, err) defer cleanup()
func ToProtoComponentRef ¶
func ToProtoComponentRef(config *ref.ComponentRefConfig) *pb.ComponentRefConfig
func ToProtoSecretRef ¶
func ToProtoSecretRef(secrets []*ref.SecretRefConfig) []*pb.SecretRefConfig
Types ¶
type CallbackFunc ¶
type CallbackFunc func(compType string, dialer GRPCConnectionDialer) Component
type GRPCConnectionDialer ¶
type GRPCConnectionDialer func(ctx context.Context, opts ...grpc.DialOption) (*grpc.ClientConn, error)
func SocketDialer ¶
func SocketDialer(socket string, additionalOpts ...grpc.DialOption) GRPCConnectionDialer
SocketDialer creates a dialer for the given socket.
func (GRPCConnectionDialer) WithOptions ¶
func (g GRPCConnectionDialer) WithOptions(newOpts ...grpc.DialOption) GRPCConnectionDialer
WithOptions returns a new connection dialer that adds the new options to it.