Documentation ¶
Index ¶
- Constants
- Variables
- func BeforeStop(callback func() error)
- func GetServiceName(serviceName string) string
- func WaitForOSSignal(timeout time.Duration)
- type Application
- func (application *Application) BeforeStop(callback func() error)
- func (application *Application) Configuration() *config
- func (application *Application) ConsulConfigurationKey() string
- func (application *Application) ContainerName() string
- func (application *Application) Context() context.Context
- func (application *Application) DefaultSubscriptionClientOptions() func(options *microClient.PublishOptions)
- func (application *Application) DefaultSubscriptionServerOptions() func(options *microServer.SubscriberOptions)
- func (application *Application) DeregisterApplication(topic string, message interface{})
- func (application *Application) Environment() string
- func (application *Application) EnvironmentDescriptor() ApplicationEnvironment
- func (application *Application) EnvironmentPrefix() string
- func (application *Application) InitializeConfiguration() error
- func (application *Application) InitializeLogger()
- func (application *Application) InitializeMicroService() error
- func (application *Application) ManagerServiceName() string
- func (application *Application) Name() string
- func (application *Application) OriginalName() string
- func (application *Application) OriginalVendorName() string
- func (application *Application) Port() uint64
- func (application *Application) PrettyVersionCLI()
- func (application *Application) PrettyVersionForAPI() string
- func (application *Application) RegisterApplication(topic string, message interface{})
- func (application *Application) RegisterSubscriptionServer(subscriptionName string, processor interface{}, ...)
- func (application *Application) RunServiceHealthCheck(topic string, message interface{})
- func (application *Application) SendMessageToTopic(subscriptionName string, message interface{}, ...)
- func (application *Application) Service() micro.Service
- func (application *Application) ServiceName() string
- func (application *Application) StartMicroService(registrations ...Registration)
- func (application *Application) UUID() string
- func (application *Application) Vendor() string
- func (application *Application) Version() string
- func (application *Application) VersionDescriptor() VersionDescriptor
- type ApplicationEnvironment
- type ApplicationKey
- type BrokerInterface
- type Duration
- type EnvironmentType
- type Micro
- type NatsBroker
- type Registration
- type VersionDescriptor
- func (version VersionDescriptor) Equal(otherVersion VersionDescriptor) bool
- func (version *VersionDescriptor) Initialize()
- func (version VersionDescriptor) Newer(otherVersion VersionDescriptor) bool
- func (version VersionDescriptor) Older(otherVersion VersionDescriptor) bool
- func (version VersionDescriptor) String() string
- func (version VersionDescriptor) StringPretty() string
- func (version VersionDescriptor) StringVersion() string
- func (version VersionDescriptor) StringWithBranch() string
- func (version VersionDescriptor) StringWithBranchAndBuildDate() string
- func (version VersionDescriptor) StringWithBuildDate() string
Constants ¶
const ( RedisServiceName = "micro.redis" DatabaseServiceName = "micro.database" TMDBServiceName = "micro.tmdb" JackettServiceName = "micro.jackett" TorrentServiceName = "micro.torrent" )
const (
ServiceID errors.Service = 0
)
Variables ¶
var ( InvalidBrokerConfiguration = errors.Error{ Code: errors.Code{ Service: ServiceID, ErrorType: errors.TypeUndefined, ErrorNumber: 1, }, Message: "Invalid broken configuration", } BrokerKeyNotFound = errors.Error{ Code: errors.Code{ Service: ServiceID, ErrorType: errors.TypeUndefined, ErrorNumber: 2, }, Message: "Broker key could not be found", } BrokerNotConfigured = errors.Error{ Code: errors.Code{ Service: ServiceID, ErrorType: errors.TypeUndefined, ErrorNumber: 3, }, Message: "Broker is not configured yet", } BrokerNotSupported = errors.Error{ Code: errors.Code{ Service: ServiceID, ErrorType: errors.TypeUndefined, ErrorNumber: 4, }, Message: "Specified broker is not supported: %s", } BrokerInitializationError = errors.Error{ Code: errors.Code{ Service: ServiceID, ErrorType: errors.TypeUndefined, ErrorNumber: 5, }, Message: "Broker failed to complete initialization process", } BrokerConnectionError = errors.Error{ Code: errors.Code{ Service: ServiceID, ErrorType: errors.TypeUndefined, ErrorNumber: 6, }, Message: "Failed to connect to broker", } MicroServiceNotInitialized = errors.Error{ Code: errors.Code{ Service: ServiceID, ErrorType: errors.TypeUndefined, ErrorNumber: 7, }, Message: "You have to initialize micro service first", } BeforeStopCallbackError = errors.Error{ Code: errors.Code{ Service: ServiceID, ErrorType: errors.TypeUndefined, ErrorNumber: 8, }, Message: "Failed to execute `beforeStop` callback as it has errored", } UnableToConnectToConsul = errors.Error{ Code: errors.Code{ Service: ServiceID, ErrorType: errors.TypeNetwork, ErrorNumber: 1, }, Message: "Unable to connect to remote Consul instance", } UnableToGetKeyFromConsulKV = errors.Error{ Code: errors.Code{ Service: ServiceID, ErrorType: errors.TypeLibrary, ErrorNumber: 1, }, Message: "Unable to retrieve requested key from Consul Key/Value storage: %s", } UnableToGetServiceConfigurationFromConsulKV = errors.Error{ Code: errors.Code{ Service: ServiceID, ErrorType: errors.TypeLibrary, ErrorNumber: 2, }, Message: "Unable to retrieve microservice configuration from Consul using service key: %s", } UnableToGetSubscriptionsInformationForVendorFromConsul = errors.Error{ Code: errors.Code{ Service: ServiceID, ErrorType: errors.TypeLibrary, ErrorNumber: 3, }, Message: "Unable to retrieve microservice configuration from Consul using service key: %s", } UnableToDecodeSubscriptionsConfiguration = errors.Error{ Code: errors.Code{ Service: ServiceID, ErrorType: errors.TypeLibrary, ErrorNumber: 4, }, Message: "Unable to decode subscriptions configuration retrieved from Consul", } ViperUnableToMergeConfigs = errors.Error{ Code: errors.Code{ Service: ServiceID, ErrorType: errors.TypeLibrary, ErrorNumber: 5, }, Message: "Viper is not able to merge provided configurations", } )
var ( BuildDateLocal string BuildDateUTC string GitCommitLong string GitCommitShort string GitBranch string GitState string GitAuthor string GitVersion string GitSummary string )
var DefaultVersion = VersionDescriptor{
Major: 1,
Minor: 0,
Patch: 0,
Build: "",
BuiltOn: "",
}
var EnvironmentLookup = map[EnvironmentType]string{ Development: "development", Staging: "staging", Debug: "debug", Production: "production", }
Functions ¶
func GetServiceName ¶
func WaitForOSSignal ¶
Wait for the OS signal, run callback and then terminate application
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
func (*Application) BeforeStop ¶
func (application *Application) BeforeStop(callback func() error)
Add new callback which will be called before application is stopped
func (*Application) Configuration ¶
func (application *Application) Configuration() *config
Get application configuration
func (*Application) ConsulConfigurationKey ¶
func (application *Application) ConsulConfigurationKey() string
Generate consul configuration key for microservice
func (*Application) ContainerName ¶
func (application *Application) ContainerName() string
Get application container name
func (*Application) Context ¶
func (application *Application) Context() context.Context
Get application context
func (*Application) DefaultSubscriptionClientOptions ¶
func (application *Application) DefaultSubscriptionClientOptions() func(options *microClient.PublishOptions)
Get default publisher options
func (*Application) DefaultSubscriptionServerOptions ¶
func (application *Application) DefaultSubscriptionServerOptions() func(options *microServer.SubscriberOptions)
Get default subscription options
func (*Application) DeregisterApplication ¶
func (application *Application) DeregisterApplication(topic string, message interface{})
Deregister Application
func (*Application) Environment ¶
func (application *Application) Environment() string
Get application environment as string
func (*Application) EnvironmentDescriptor ¶
func (application *Application) EnvironmentDescriptor() ApplicationEnvironment
Get application environment descriptor
func (*Application) EnvironmentPrefix ¶
func (application *Application) EnvironmentPrefix() string
Get application environment prefix
func (*Application) InitializeConfiguration ¶
func (application *Application) InitializeConfiguration() error
Initialize application configuration
func (*Application) InitializeLogger ¶
func (application *Application) InitializeLogger()
Initialize logger
func (*Application) InitializeMicroService ¶
func (application *Application) InitializeMicroService() error
Initialize go-micro service
func (*Application) ManagerServiceName ¶
func (application *Application) ManagerServiceName() string
Get service name for manager
func (*Application) OriginalName ¶
func (application *Application) OriginalName() string
Get application original name
func (*Application) OriginalVendorName ¶
func (application *Application) OriginalVendorName() string
Get application original vendor name
func (*Application) Port ¶
func (application *Application) Port() uint64
Get port application is running on
func (*Application) PrettyVersionCLI ¶
func (application *Application) PrettyVersionCLI()
Application Version Information for CLI
func (*Application) PrettyVersionForAPI ¶
func (application *Application) PrettyVersionForAPI() string
Application information for API
func (*Application) RegisterApplication ¶
func (application *Application) RegisterApplication(topic string, message interface{})
Register application
func (*Application) RegisterSubscriptionServer ¶
func (application *Application) RegisterSubscriptionServer(subscriptionName string, processor interface{}, options func(options *microServer.SubscriberOptions))
Register subscriptions server
func (*Application) RunServiceHealthCheck ¶
func (application *Application) RunServiceHealthCheck(topic string, message interface{})
Send data to the manager
func (*Application) SendMessageToTopic ¶
func (application *Application) SendMessageToTopic(subscriptionName string, message interface{}, options func(options *microClient.PublishOptions), panicOnError bool)
Register subscriptions client
func (*Application) Service ¶
func (application *Application) Service() micro.Service
Get micro service instance
func (*Application) ServiceName ¶
func (application *Application) ServiceName() string
Get application service name
func (*Application) StartMicroService ¶
func (application *Application) StartMicroService(registrations ...Registration)
Start microservice
func (*Application) Vendor ¶
func (application *Application) Vendor() string
Get application vendor name
func (*Application) Version ¶
func (application *Application) Version() string
Get application version as string
func (*Application) VersionDescriptor ¶
func (application *Application) VersionDescriptor() VersionDescriptor
Get application version descriptor
type ApplicationEnvironment ¶
type ApplicationEnvironment struct { Name string Type EnvironmentType }
func GetApplicationEnvironment ¶
func GetApplicationEnvironment() ApplicationEnvironment
Get application environment
type ApplicationKey ¶
type ApplicationKey struct{}
type BrokerInterface ¶
type EnvironmentType ¶
type EnvironmentType uint8
const ( Development EnvironmentType = 1 Staging EnvironmentType = 2 Debug EnvironmentType = 3 Production EnvironmentType = 4 )
type Micro ¶
type Micro struct {
Service micro.Service
}
func (*Micro) Initialize ¶
func (handler *Micro) Initialize(application *Application) error
type NatsBroker ¶
type NatsBroker struct { Endpoint string `json:"endpoint"` ClusterID string `json:"cluster_id"` Timeout struct { Connect Duration `json:"connect"` Ack Duration `json:"ack"` } DiscoverPrefix string `json:"discover_prefix"` MaxPubAcks int `json:"max_pub_acks"` Ping struct { Interval int `json:"interval"` MaxOut int `json:"max_out"` } }
func (*NatsBroker) Decode ¶
func (broker *NatsBroker) Decode(decode []byte) error
func (*NatsBroker) Name ¶
func (broker *NatsBroker) Name() string
type Registration ¶
type Registration struct { Topic string Event interface{} Options func(options *microServer.SubscriberOptions) }
type VersionDescriptor ¶
type VersionDescriptor struct { Major uint64 Minor uint64 Patch uint64 Build string BuiltOn string Branch string }
func (VersionDescriptor) Equal ¶
func (version VersionDescriptor) Equal(otherVersion VersionDescriptor) bool
Compare two versions for being equal to each other
func (*VersionDescriptor) Initialize ¶
func (version *VersionDescriptor) Initialize()
"Initialize" application version
func (VersionDescriptor) Newer ¶
func (version VersionDescriptor) Newer(otherVersion VersionDescriptor) bool
Check if application version is newer than one that is provided
func (VersionDescriptor) Older ¶
func (version VersionDescriptor) Older(otherVersion VersionDescriptor) bool
Check if current application version is older than one that is provided
func (VersionDescriptor) String ¶
func (version VersionDescriptor) String() string
Convert application version to string
func (VersionDescriptor) StringPretty ¶
func (version VersionDescriptor) StringPretty() string
Pretty application version
func (VersionDescriptor) StringVersion ¶
func (version VersionDescriptor) StringVersion() string
Just version number string
func (VersionDescriptor) StringWithBranch ¶
func (version VersionDescriptor) StringWithBranch() string
Convert application version to string with branch name
func (VersionDescriptor) StringWithBranchAndBuildDate ¶
func (version VersionDescriptor) StringWithBranchAndBuildDate() string
Convert application version to string branch name and build date
func (VersionDescriptor) StringWithBuildDate ¶
func (version VersionDescriptor) StringWithBuildDate() string
Convert application version to string with build date