Documentation ¶
Index ¶
- type DBRegister
- type HandlerServer
- type IService
- type Namespace
- type RegisterFunc
- type RegistrationParams
- type Registry
- type Service
- func (s Service[S]) DBMigrations() *embed.FS
- func (s Service[S]) GetNamespace() string
- func (s Service[S]) GetServiceDesc() *grpc.ServiceDesc
- func (s Service[S]) IsDBRequired() bool
- func (s Service[S]) IsStarted() bool
- func (s Service[S]) RegisterConnectRPCServiceHandler(_ context.Context, connectRPC *server.ConnectRPC) error
- func (s Service[S]) RegisterGRPCGatewayHandler(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) errordeprecated
- func (s *Service[S]) RegisterHTTPHandlers(ctx context.Context, mux *runtime.ServeMux) errordeprecated
- func (s Service[S]) Shutdown() error
- func (s *Service[S]) Start(ctx context.Context, params RegistrationParams) error
- type ServiceConfig
- type ServiceOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBRegister ¶ added in v0.3.0
type DBRegister struct { // Required is a flag that indicates whether the service requires a database connection. Required bool // Migrations is an embedded filesystem that contains the Goose SQL migrations for the service. // This is required to support the `migrate` command or the `runMigrations` configuration option. // More information on Goose can be found at https://github.com/pressly/goose Migrations *embed.FS }
DBRegister is a struct that holds the information needed to register a service with a database
type IService ¶ added in v0.4.27
type IService interface { IsDBRequired() bool DBMigrations() *embed.FS GetNamespace() string GetServiceDesc() *grpc.ServiceDesc Start(ctx context.Context, params RegistrationParams) error IsStarted() bool Shutdown() error RegisterConnectRPCServiceHandler(context.Context, *server.ConnectRPC) error RegisterGRPCGatewayHandler(context.Context, *runtime.ServeMux, string, []grpc.DialOption) error RegisterHTTPHandlers(context.Context, *runtime.ServeMux) error }
type RegisterFunc ¶
type RegisterFunc[S any] func(RegistrationParams) (impl S, HandlerServer HandlerServer)
type RegistrationParams ¶
type RegistrationParams struct { // Config scoped to the service config. Since the main config contains all the service configs, // which could have need-to-know information we don't want to expose it to all services. Config ServiceConfig // OTDF is the OpenTDF server that can be used to interact with the OpenTDFServer instance. OTDF *server.OpenTDFServer // DBClient is the database client that can be used to interact with the database. This client // is scoped to the service namespace and will not be shared with other service namespaces. DBClient *db.Client // SDK is the OpenTDF SDK that can be used to interact with the OpenTDF SDK. This is useful for // gRPC Inter Process Communication (IPC) between services. This ensures the services are // communicating with each other by contract as well as supporting the various deployment models // that OpenTDF supports. SDK *sdk.SDK // Logger is the logger that can be used to log messages. This logger is scoped to the service Logger *logger.Logger trace.Tracer // RegisterWellKnownConfig is a function that can be used to register a well-known configuration WellKnownConfig func(namespace string, config any) error // RegisterReadinessCheck is a function that can be used to register a readiness check for the // service. This is useful for services that need to perform some initialization before they are // ready to serve requests. This function should be called in the RegisterFunc function. RegisterReadinessCheck func(namespace string, check func(context.Context) error) error }
RegistrationParams is a struct that holds the parameters needed to register a service with the service registry. These parameters are passed to the RegisterFunc function defined in the Registration struct.
type Registry ¶ added in v0.4.18
Registry represents a map of service namespaces.
func NewServiceRegistry ¶ added in v0.4.18
func NewServiceRegistry() Registry
NewServiceRegistry creates a new instance of the service registry.
func (Registry) GetNamespace ¶ added in v0.4.18
GetNamespace returns the namespace with the given name from the service registry.
func (Registry) RegisterCoreService ¶ added in v0.4.18
RegisterCoreService registers a core service with the given registration information. It calls the RegisterService method of the Registry instance with the provided registration and service type "core". Returns an error if the registration fails.
func (Registry) RegisterService ¶ added in v0.4.18
RegisterService registers a service in the service registry. It takes a Registration object and a mode string as parameters. The Registration object contains information about the service to be registered, such as the namespace and service description. The mode string specifies the mode in which the service should be registered. It returns an error if the service is already registered in the specified namespace.
func (Registry) Shutdown ¶ added in v0.4.18
func (reg Registry) Shutdown()
Shutdown stops all the services in the service registry. It iterates over each namespace and service in the registry, checks if the service has a Close method and if it has been started, and then calls the Close method to stop the service.
type Service ¶
type Service[S any] struct { // Started is a flag that indicates whether the service has been started Started bool // Close is a function that can be called to close the service Close func() // Service Options ServiceOptions[S] // contains filtered or unexported fields }
Service is a struct that holds the registration information for a service as well as the state of the service within the instance of the platform.
func (Service[S]) DBMigrations ¶ added in v0.4.27
func (Service[S]) GetNamespace ¶ added in v0.4.27
func (Service[S]) GetServiceDesc ¶ added in v0.4.27
func (s Service[S]) GetServiceDesc() *grpc.ServiceDesc
func (Service[S]) IsDBRequired ¶ added in v0.4.27
func (Service[S]) RegisterConnectRPCServiceHandler ¶ added in v0.4.27
func (Service[S]) RegisterGRPCGatewayHandler
deprecated
added in
v0.4.27
func (s Service[S]) RegisterGRPCGatewayHandler(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) error
Deprecated: RegisterConnectRPCServiceHandler is deprecated and should not be used going forward. We will be looking onto other alternatives like bufconnect to replace this. RegisterConnectRPCServiceHandler registers an HTTP server with the service. It takes a context, a ServeMux, and an implementation function as parameters. If the service did not register a handler, it returns an error.
func (*Service[S]) RegisterHTTPHandlers
deprecated
added in
v0.4.27
Deprecated: RegisterHTTPServer is deprecated and should not be used going forward. We will be looking onto other alternatives like bufconnect to replace this. RegisterHTTPServer registers an HTTP server with the service. It takes a context, a ServeMux, and an implementation function as parameters. If the service did not register a handler, it returns an error.
func (*Service[S]) Start ¶ added in v0.4.18
func (s *Service[S]) Start(ctx context.Context, params RegistrationParams) error
Start starts the service and performs necessary initialization steps. It returns an error if the service is already started or if there is an issue running database migrations.
type ServiceConfig ¶
type ServiceOptions ¶ added in v0.4.27
type ServiceOptions[S any] struct { // Namespace is the namespace of the service. One or more gRPC services can be registered under // the same namespace. Namespace string // ServiceDesc is the gRPC service descriptor. For non-gRPC services, this can be mocked out, // but at minimum, the ServiceName field must be set ServiceDesc *grpc.ServiceDesc // RegisterFunc is the function that will be called to register the service RegisterFunc RegisterFunc[S] // ConnectRPCServiceHandler is the function that will be called to register the service with the ConnectRPCFunc func(S, ...connect.HandlerOption) (string, http.Handler) // Deprecated: Registers a gRPC service with the gRPC gateway GRPCGateayFunc func(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) // DB is optional and used to register the service with a database DB DBRegister // contains filtered or unexported fields }