Documentation ¶
Index ¶
- func ServiceName(name string) service.Name
- type Env
- type MapEnv
- func (m *MapEnv) CoupledNamespace() string
- func (m *MapEnv) CoupledPort() int32
- func (m *MapEnv) DeploymentEnv() definition.ServiceDeploy
- func (m *MapEnv) Get(key string) interface{}
- func (m *MapEnv) GrpcPort() int32
- func (m *MapEnv) HttpPort() int32
- func (m *MapEnv) IsCICD() bool
- func (m *MapEnv) TrackerHeaderName() string
- type Service
- func (s *Service) Abort(message string, err error)
- func (s *Service) CustomDefinitions() map[string]interface{}
- func (s *Service) DeployEnvironment() definition.ServiceDeploy
- func (s *Service) Env(name string) string
- func (s *Service) Errors() errorsApi.ErrorFactory
- func (s *Service) Feature(ctx context.Context, target interface{}) error
- func (s *Service) Logger() loggerApi.Logger
- func (s *Service) ServiceName() string
- func (s *Service) SetupTest(ctx context.Context, t *testing.Testing) *ServiceTesting
- func (s *Service) Start(srv interface{})
- func (s *Service) WithExternalFeatures(features *plugin.FeatureSet) *Service
- func (s *Service) WithExternalServices(services *plugin.ServiceSet) *Service
- type ServiceTesting
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ServiceName ¶
ServiceName is the way to retrieve a service name from a string.
Types ¶
type Env ¶
type Env struct { DeploymentEnv definition.ServiceDeploy `env:"MIKROS_SERVICE_DEPLOY,default_value=local"` TrackerHeaderName string `env:"MIKROS_TRACKER_HEADER_NAME,default_value=X-Request-ID"` // CI/CD settings IsCICD bool `env:"MIKROS_CICD_TEST,default_value=false"` // Coupled clients CoupledNamespace string `env:"MIKROS_COUPLED_NAMESPACE"` CoupledPort int32 `env:"MIKROS_COUPLED_PORT,default_value=7070"` // Default connection ports GrpcPort int32 `env:"MIKROS_GRPC_PORT,default_value=7070"` HttpPort int32 `env:"MIKROS_HTTP_PORT,default_value=8080"` // contains filtered or unexported fields }
Env is the main framework environment structure. It holds only variables common for the whole project.
It is also the mechanism to hold all environment variables declared directly inside the 'service.toml' file.
type MapEnv ¶
type MapEnv struct {
// contains filtered or unexported fields
}
MapEnv is an Env subtype that can be passed to the plugin package options.
func (*MapEnv) CoupledNamespace ¶
func (*MapEnv) CoupledPort ¶
func (*MapEnv) DeploymentEnv ¶
func (m *MapEnv) DeploymentEnv() definition.ServiceDeploy
func (*MapEnv) TrackerHeaderName ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the object which represents a service application.
func NewService ¶
func NewService(opt *options.NewServiceOptions) *Service
NewService creates a new Service object for building and putting to run a new application.
We don't return an error here to force the application to end in case something wrong happens.
func (*Service) Abort ¶
Abort is a helper method to abort services in the right way, when external initialization is needed.
func (*Service) CustomDefinitions ¶
CustomDefinitions gives the service access to the service custom settings that it may have put inside the 'service.toml' file.
Note that these settings correspond to everything under the service object inside the TOML file.
func (*Service) DeployEnvironment ¶
func (s *Service) DeployEnvironment() definition.ServiceDeploy
DeployEnvironment exposes the current service deploymentEnv environment.
func (*Service) Errors ¶
func (s *Service) Errors() errorsApi.ErrorFactory
Errors gives access to the errors API from inside a service context.
func (*Service) Feature ¶
Feature is the service mechanism to have access to an external feature public API.
func (*Service) ServiceName ¶
ServiceName gives back the service name.
func (*Service) SetupTest ¶
SetupTest is an api that should start the testing environment for a unit test.
func (*Service) Start ¶
func (s *Service) Start(srv interface{})
Start puts the service in execution mode and blocks execution. This function should be the last one called by the service.
We don't return an error here so that the service does not need to handle it inside its code. We abort in case of an error.
func (*Service) WithExternalFeatures ¶
func (s *Service) WithExternalFeatures(features *plugin.FeatureSet) *Service
WithExternalFeatures allows a service to add external features into it, so they can be used from it.
func (*Service) WithExternalServices ¶
func (s *Service) WithExternalServices(services *plugin.ServiceSet) *Service
WithExternalServices allows a service to add external service implementations into it.
type ServiceTesting ¶
type ServiceTesting struct {
// contains filtered or unexported fields
}
ServiceTesting is an object created by a Service.SetupTest call.
It should be used when creating unit tests that need to use features, internal or external, and require some kind of setup/teardown mechanism.
func (*ServiceTesting) Do ¶
func (s *ServiceTesting) Do(ctx context.Context) error
Do is a function that executes tests from inside all registered features.
func (*ServiceTesting) Teardown ¶
func (s *ServiceTesting) Teardown(ctx context.Context)
Teardown releases every resource allocated by the SetupTest call.
Directories ¶
Path | Synopsis |
---|---|
apis
|
|
components
|
|
testing
Package testing is a framework package to be used inside services unit tests providing an API to build specific services unit tests.
|
Package testing is a framework package to be used inside services unit tests providing an API to build specific services unit tests. |
internal
|
|
components/validations
Package validations adds an internal framework API to validate structures without tag annotations.
|
Package validations adds an internal framework API to validate structures without tag annotations. |