Documentation
¶
Index ¶
- Variables
- func ParseExternalDefinitions(path string, defs interface{}) error
- func SupportedLanguages() []string
- func SupportedServiceTypes() []string
- func ValidateVersion(input string) bool
- type Definitions
- func (d *Definitions) AddExternalFeatureDefinitions(name string, defs ExternalFeatureEntry)
- func (d *Definitions) AddExternalServiceDefinitions(name string, defs ExternalServiceEntry)
- func (d *Definitions) AddSupportedServiceType(name string)
- func (d *Definitions) ExternalFeatureDefinitions(name string) (ExternalFeatureEntry, error)
- func (d *Definitions) ExternalServiceDefinitions(name string) (ExternalServiceEntry, error)
- func (d *Definitions) IsServiceType(serviceType ServiceType) bool
- func (d *Definitions) LoadCustomServiceDefinitions(srv interface{}) error
- func (d *Definitions) LoadService(serviceType ServiceType) (map[string]interface{}, bool)
- func (d *Definitions) Path() string
- func (d *Definitions) ServiceName() service.Name
- func (d *Definitions) ServiceTypes() map[ServiceType]service.ServerPort
- func (d *Definitions) ServiceTypesAsString() string
- func (d *Definitions) Validate() error
- type ExternalFeatureEntry
- type ExternalServiceEntry
- type FeatureEntry
- type Features
- type GrpcClient
- type Log
- type ServiceDeploy
- type ServiceType
- type Tests
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ( ServiceType_gRPC = CreateServiceType("grpc") ServiceType_HTTPSpec = CreateServiceType("http-spec") ServiceType_HTTP = CreateServiceType("http") ServiceType_Worker = CreateServiceType("worker") ServiceType_Script = CreateServiceType("script") )
Functions ¶
func ParseExternalDefinitions ¶
ParseExternalDefinitions allows loading specific service definitions from its file using a custom target. This provides external features (plugins) to load their definitions from the same file into their own structures.
func SupportedLanguages ¶
func SupportedLanguages() []string
SupportedLanguages gives a slice of supported programming languages.
func SupportedServiceTypes ¶
func SupportedServiceTypes() []string
SupportedServiceTypes gives a slice of all supported service types.
func ValidateVersion ¶
ValidateVersion is a helper function to validate the version format used by services.
Types ¶
type Definitions ¶
type Definitions struct {
Name string `toml:"name" validate:"required"`
Types []string `toml:"types" validate:"required,single_script,no_duplicated_service,dive,service_type"`
Version string `toml:"version" validate:"required,version"`
Language string `toml:"language" validate:"required,oneof=go rust"`
Product string `toml:"product" validate:"required"`
Envs []string `toml:"envs,omitempty" validate:"dive,ascii,uppercase"`
Features Features `toml:"features,omitempty"`
Log Log `toml:"log,omitempty"`
Tests Tests `toml:"tests"`
Service map[string]interface{} `toml:"service,omitempty"`
Clients map[string]GrpcClient `toml:"clients,omitempty"`
Services map[string]map[string]interface{} `toml:"services,omitempty"`
// contains filtered or unexported fields
}
Definitions is a structure representation of a 'service.toml' file. It holds all service information that will be used to initialize it as well as all features it will have when executing.
func New ¶
func New() (*Definitions, error)
New creates a new Definitions structure initializing the service features with default values.
func Parse ¶
func Parse() (*Definitions, error)
Parse is responsible for loading the service definitions file (service.toml) into a proper Definitions structure.
func ParseFromFile ¶ added in v0.16.0
func ParseFromFile(path string) (*Definitions, error)
ParseFromFile is an alternative way of loading a service definitions file for outside projects.
func (*Definitions) AddExternalFeatureDefinitions ¶
func (d *Definitions) AddExternalFeatureDefinitions(name string, defs ExternalFeatureEntry)
AddExternalFeatureDefinitions adds definitions from external features into the Definitions object.
func (*Definitions) AddExternalServiceDefinitions ¶
func (d *Definitions) AddExternalServiceDefinitions(name string, defs ExternalServiceEntry)
AddExternalServiceDefinitions adds definitions from external service into the Definitions object.
func (*Definitions) AddSupportedServiceType ¶
func (d *Definitions) AddSupportedServiceType(name string)
AddSupportedServiceType adds a new service type as supported by the service definitions.
func (*Definitions) ExternalFeatureDefinitions ¶
func (d *Definitions) ExternalFeatureDefinitions(name string) (ExternalFeatureEntry, error)
ExternalFeatureDefinitions retrieves definitions from an external feature previously added into the Definitions.
func (*Definitions) ExternalServiceDefinitions ¶
func (d *Definitions) ExternalServiceDefinitions(name string) (ExternalServiceEntry, error)
ExternalServiceDefinitions retrieves definitions from an external service previously added into the Definitions.
func (*Definitions) IsServiceType ¶
func (d *Definitions) IsServiceType(serviceType ServiceType) bool
IsServiceType checks if the current service definitions is of a specific service type.
func (*Definitions) LoadCustomServiceDefinitions ¶ added in v0.12.0
func (d *Definitions) LoadCustomServiceDefinitions(srv interface{}) error
LoadCustomServiceDefinitions loads the service object directly inside the service member tagged with "definitions".
func (*Definitions) LoadService ¶
func (d *Definitions) LoadService(serviceType ServiceType) (map[string]interface{}, bool)
LoadService retrieves only definitions from a specific service type.
func (*Definitions) Path ¶ added in v0.13.0
func (d *Definitions) Path() string
Path returns the original path that was loaded to the current definitions.
func (*Definitions) ServiceName ¶
func (d *Definitions) ServiceName() service.Name
ServiceName returns the service.Name loaded from the definitions.
func (*Definitions) ServiceTypes ¶
func (d *Definitions) ServiceTypes() map[ServiceType]service.ServerPort
ServiceTypes gives back all service types found inside the service definitions.
func (*Definitions) ServiceTypesAsString ¶
func (d *Definitions) ServiceTypesAsString() string
func (*Definitions) Validate ¶
func (d *Definitions) Validate() error
Validate validates if all data loaded from the service definitions is correct.
It also validates external services and external features custom definitions.
type ExternalFeatureEntry ¶
type ExternalFeatureEntry interface {
// Enabled must return true or false if the feature is enabled or not.
Enabled() bool
// Validate should validate if the custom settings are valid or not.
Validate() error
}
ExternalFeatureEntry is a behavior that all external feature must have to be supported by the package Definitions object.
type ExternalServiceEntry ¶
type ExternalServiceEntry interface {
// Name must return the service name that the definitions will support.
Name() string
// Validate should validate if the custom settings are valid or not.
Validate() error
}
ExternalServiceEntry is a behavior that all external services implementation must have to be supported by the Definitions object.
type FeatureEntry ¶
type FeatureEntry struct {
// Enabled should enable or disable the feature. Default is always to start
// with the feature disabled.
Enabled bool `toml:"enabled,omitempty"`
}
FeatureEntry is a structure that an external feature should have so that all presents at least a few common settings.
func (FeatureEntry) IsEnabled ¶
func (f FeatureEntry) IsEnabled() bool
type Features ¶
type Features struct {
// contains filtered or unexported fields
}
Features is a structure that defines a list of features that a service may use or not when executing. By convention, all features are turned off by default, and should be explicitly enabled when desired using the 'enabled' key.
type GrpcClient ¶
type ServiceDeploy ¶
type ServiceDeploy int32
const ( ServiceDeploy_Unknown ServiceDeploy = iota ServiceDeploy_Production ServiceDeploy_Test ServiceDeploy_Development ServiceDeploy_Local )
func (ServiceDeploy) FromString ¶
func (e ServiceDeploy) FromString(in string) ServiceDeploy
func (ServiceDeploy) String ¶
func (e ServiceDeploy) String() string
func (*ServiceDeploy) UnmarshalText ¶ added in v0.18.0
func (e *ServiceDeploy) UnmarshalText(text []byte) error
type ServiceType ¶
type ServiceType struct {
// contains filtered or unexported fields
}
func CreateServiceType ¶
func CreateServiceType(name string) ServiceType
func (ServiceType) String ¶
func (s ServiceType) String() string