services

package
v0.0.0-...-187538d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package services implements the components required to serve the services

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServiceGeneric        = errors.New("service: generic error")
	ErrServiceInvalidKind    = errors.New("service: invalid kind")
	ErrServiceInvalidAppData = errors.New("service: invalid app data")
	ErrServiceInvalidPort    = errors.New("service: invalid port")
)

Functions

This section is empty.

Types

type EndpointContext

type EndpointContext struct {
	// contains filtered or unexported fields
}

EndpointContext is the endpoint context.

func NewEndpointContext

func NewEndpointContext(serviceContext *ServiceContext, port int) (*EndpointContext, error)

NewEndpointContext creates a new endpoint context.

func (*EndpointContext) GetContext

func (e *EndpointContext) GetContext() context.Context

GetContext returns the context.

func (*EndpointContext) GetLogMessage

func (e *EndpointContext) GetLogMessage(message string) string

GetLogMessage returns a well formatted log message.

func (*EndpointContext) GetLogger

func (e *EndpointContext) GetLogger() *zap.Logger

GetLogger returns the logger.

func (*EndpointContext) GetParentLoggerMessage

func (e *EndpointContext) GetParentLoggerMessage() string

GetParentLoggerMessage returns the parent logger message.

func (*EndpointContext) GetPort

func (e *EndpointContext) GetPort() int

GetPort returns

type EndpointInitializer

type EndpointInitializer struct {
	// contains filtered or unexported fields
}

EndpointInitializer is the service endpoint factory.

func NewEndpointInitializer

func NewEndpointInitializer(service ServiceKind, port int, registration func(*grpc.Server, *ServiceContext, *EndpointContext, *azstorage.StorageConnector) error) (EndpointInitializer, error)

NewEndpointInitializer creates a new service endpoint factory.

func (EndpointInitializer) GetPort

func (d EndpointInitializer) GetPort() int

GetPort returns the port.

func (EndpointInitializer) GetRegistration

GetRegistration returns the registration.

func (EndpointInitializer) GetService

func (d EndpointInitializer) GetService() ServiceKind

GetService returns the service kind.

type HostContext

type HostContext struct {
	// contains filtered or unexported fields
}

HostContext is the host context.

func NewHostContext

func NewHostContext(host HostKind, hostable Hostable, logger *zap.Logger, appData string) (*HostContext, error)

NewHostContext creates a new host context.

func (*HostContext) GetAppData

func (h *HostContext) GetAppData() string

GetAppData returns the app data.

func (*HostContext) GetContext

func (h *HostContext) GetContext() context.Context

GetContext returns the context.

func (*HostContext) GetHost

func (h *HostContext) GetHost() HostKind

GetHost returns the host.

func (*HostContext) GetLogMessage

func (h *HostContext) GetLogMessage(message string) string

GetLogMessage returns a well formatted log message.

func (*HostContext) GetLogger

func (h *HostContext) GetLogger() *zap.Logger

GetLogger returns the logger.

func (*HostContext) GetParentLoggerMessage

func (h *HostContext) GetParentLoggerMessage() string

GetParentLoggerMessage returns the parent logger message.

func (*HostContext) Shutdown

func (h *HostContext) Shutdown(ctx context.Context)

Shutdown shuts down the service.

type HostInfo

type HostInfo struct {
	Name  string
	Use   string
	Short string
	Long  string
}

HostInfo declares the host information.

type HostKind

type HostKind string

HostKind represents the type of service host.

const (
	HostAllInOne HostKind = "ALL-IN-ONE"
	HostAAP      HostKind = "AAP"
	HostPAP      HostKind = "PAP"
	HostPIP      HostKind = "PIP"
	HostPRP      HostKind = "PRP"
	HostIDP      HostKind = "IDP"
	HostPDP      HostKind = "PDP"
)

func NewHostKindFromString

func NewHostKindFromString(host string) (HostKind, error)

NewHostKindFromString creates a new host kind from a string.

func (HostKind) CanHost

func (s HostKind) CanHost(service ServiceKind, hosts []HostKind) bool

CanHost returns true if the service can host the desired service.

func (HostKind) Equal

func (s HostKind) Equal(host HostKind) bool

Equal returns true if the host is equal to the input host.

func (HostKind) GetServices

func (s HostKind) GetServices(hosts []HostKind, services []ServiceKind) []ServiceKind

GetServices returns the hostable services.

func (HostKind) IsValid

func (s HostKind) IsValid(hosts []HostKind) bool

IsValid returns true if the host is valid.

func (HostKind) String

func (s HostKind) String() string

String returns the string representation of the host.

type Hostable

type Hostable interface {
	Serve(ctx context.Context, onShutdown func()) (bool, error)
	Shutdown(context.Context)
}

Hostable must be implemented by hostable components.

type ServiceContext

type ServiceContext struct {
	// contains filtered or unexported fields
}

ServiceContext is the service context.

func NewServiceContext

func NewServiceContext(hostContext *HostContext, service ServiceKind) (*ServiceContext, error)

NewServiceContext creates a new service context.

func (*ServiceContext) GetAppData

func (s *ServiceContext) GetAppData() string

GetAppData returns the app data.

func (*ServiceContext) GetContext

func (s *ServiceContext) GetContext() context.Context

GetContext returns the context.

func (*ServiceContext) GetLogMessage

func (s *ServiceContext) GetLogMessage(message string) string

GetLogMessage returns a well formatted log message.

func (*ServiceContext) GetLogger

func (s *ServiceContext) GetLogger() *zap.Logger

GetLogger returns the logger.

func (*ServiceContext) GetParentLoggerMessage

func (s *ServiceContext) GetParentLoggerMessage() string

GetParentLoggerMessage returns the parent logger message.

func (*ServiceContext) GetService

func (s *ServiceContext) GetService() ServiceKind

GetService returns the service.

type ServiceFactory

type ServiceFactory interface {
	Create() (Serviceable, error)
}

ServiceFactory is the service factory.

type ServiceFactoryConfig

type ServiceFactoryConfig interface {
	azconfigs.Configurable
}

ServiceFactoryConfig is the service factory config.

type ServiceFactoryProvider

type ServiceFactoryProvider struct {
	// contains filtered or unexported fields
}

ServiceFactoryProvider is the service provider.

func NewServiceFactoryProvider

func NewServiceFactoryProvider(funcSvcFactCfg func() (ServiceFactoryConfig, error), funcSvcFact func(ServiceFactoryConfig) (ServiceFactory, error)) (*ServiceFactoryProvider, error)

NewServiceFactoryProvider creates a new service factory provider.

func (ServiceFactoryProvider) CreateFactory

func (p ServiceFactoryProvider) CreateFactory() (ServiceFactory, error)

CreateFactory creates a new factory.

func (ServiceFactoryProvider) GetFactoryConfig

func (p ServiceFactoryProvider) GetFactoryConfig() (ServiceFactoryConfig, error)

GetFactoryConfig returns the factory configuration.

type ServiceInitializer

type ServiceInitializer interface {
	// GetServices returns the active service kinds.
	GetServices() []ServiceKind
	// GetServicesFactories returns the list of the required services factories providers.
	GetServicesFactories() (map[ServiceKind]ServiceFactoryProvider, error)
}

ServiceInitializer is the service initializer.

type ServiceKind

type ServiceKind string

ServiceKind is the type of service.

const (
	ServiceAAP ServiceKind = "AAP"
	ServicePAP ServiceKind = "PAP"
	ServicePIP ServiceKind = "PIP"
	ServicePRP ServiceKind = "PRP"
	ServiceIDP ServiceKind = "IDP"
	ServicePDP ServiceKind = "PDP"
)

func NewServiceKindFromString

func NewServiceKindFromString(service string) (ServiceKind, error)

NewServiceKindFromString creates a new service kind from a string.

func (ServiceKind) Equal

func (s ServiceKind) Equal(service ServiceKind) bool

Equal returns true if the service kind is equal to the input service kind.

func (ServiceKind) IsValid

func (s ServiceKind) IsValid(services []ServiceKind) bool

IsValid returns true if the service kind is valid.

func (ServiceKind) String

func (s ServiceKind) String() string

String returns the string representation of the service kind.

type Serviceable

type Serviceable interface {
	// GetService returns the service kind.
	GetService() ServiceKind
	// GetEndpoints returns the service endpoints.
	GetEndpoints() ([]EndpointInitializer, error)
}

Serviceable must be implemented by all the services.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL