types

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 4 Imported by: 36

Documentation

Overview

Package types provides marker's, these are here against dependency cycles.

If this marker's would live in config for example, everything would import from config which means config isn't allowed to import a logger from log for example.

Index

Constants

View Source
const (
	PriorityLogger   = 1000
	PriorityMetrics  = 1100
	PriorityRegistry = 1200
	PriorityEvent    = 1300
	PriorityServer   = 1400
	PriorityClient   = 1500
)

Priority constants.

Variables

Components is the container for client implementations.

View Source
var (
	// DefaultSeperator is used to split a service name into config section keys.
	DefaultSeperator = "."
)

Functions

func RegisterComponent added in v0.1.1

func RegisterComponent(component Component, priority int) error

RegisterComponent adds a component to the container.

func SplitServiceName

func SplitServiceName(serviceName ServiceName) []string

SplitServiceName splits the serviceName into a string slice, separated by the global DefaultSeperator. Each item will be used as a key in the config.

Example:

ServiceName: "com.example.service"
Config:
```yaml
com:
  example:
    service:
      ...
```

Types

type Component

type Component interface {
	// Start the component. E.g. connect to the broker.
	Start() error

	// Stop the component. E.g. disconnect from the broker.
	// The context will contain a timeout, and cancelation should be respected.
	Stop(ctx context.Context) error

	// Type returns the component type, e.g. broker.
	Type() string

	// String returns the component plugin name.
	String() string
}

Component needs to be implemented by every component.

type ConfigData

type ConfigData []source.Data

ConfigData holds a single config file marshaled to map[string]any, this needs to be done to marshal data back into a components config struct.

After a config source (e.g. a yaml file, or remote resource) has been parsed, it will be passed around inside this data type. Each component then gets a list of data sources, which layer by layer get applied to eventually construct your final component config.

type ServiceName

type ServiceName string

ServiceName is the name of the Service.

type ServiceVersion added in v0.1.0

type ServiceVersion string

ServiceVersion is the version of the Service.

Jump to

Keyboard shortcuts

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