Documentation
¶
Overview ¶
Package server wires store, engine, controller and HTTP API.
Index ¶
- Constants
- func PublishAsyncApi(ctx context.Context, client *http.Client, baseUrl string, doc []byte) error
- func Version() string
- type Dependencies
- type EventDependencies
- type EventServer
- type Metrics
- func (this *Metrics) Collect(ctx context.Context, s *store.Store) error
- func (this *Metrics) CommandSent(userId string, deploymentId string)
- func (this *Metrics) Correlation(result string)
- func (this *Metrics) DeprecatedRequest(route string)
- func (this *Metrics) Handler() http.Handler
- func (this *Metrics) Incident(namespace, deploymentId, owner string)
- func (this *Metrics) InstanceEnded(namespace, deploymentId, owner string, state model.InstanceState)
- func (this *Metrics) InstanceStarted(namespace, deploymentId, owner string)
- func (this *Metrics) MarshallingLatency(endpoint string, userId string, serviceId string, functionIds string, ...)
- func (this *Metrics) Restart(namespace, deploymentId string, performed bool)
- func (this *Metrics) Run(ctx context.Context, s *store.Store, interval time.Duration, ...)
- func (this *Metrics) Task(taskType string, result string, namespace string, owner string, ...)
- func (this *Metrics) TimerDelay(delay time.Duration)
- type Server
- func (this *Server) Close() error
- func (this *Server) HandleDeviceGroupMessage(ctx context.Context, delivery []byte) error
- func (this *Server) HandleDeviceMessage(ctx context.Context, delivery []byte) error
- func (this *Server) Run(ctx context.Context) error
- func (this *Server) Start(ctx context.Context)
Constants ¶
const AsyncApiDocId = "github_com_SENERGY-Platform_automation-engine"
AsyncApiDocId names the document at api-docs-provider, by the convention of the platform services
Variables ¶
This section is empty.
Functions ¶
func PublishAsyncApi ¶ added in v0.15.0
PublishAsyncApi uploads an AsyncAPI document to api-docs-provider, which shows it in API Docs of the web-ui. A later upload replaces it.
Types ¶
type Dependencies ¶
type Dependencies struct {
// a permissions-v2 client, e.g. permissions-v2's in-process test client
Permissions permclient.Client
AdminToken auth.TokenSource
// tokens of other users; the Keycloak token exchange if not given
UserToken auth.UserTokenSource
// device command dependencies; set together, they enable device commands without URLs
DeviceRepository devicerepositoryclient.Interface
Marshaller devicecommand.Marshaller
Timescale devicecommand.Timescale
Producer devicecommand.Producer
// event debugging: stored device messages and their unmarshalling (EVT-10, DBG-18)
EventSeries events.Series
EventUnmarshaller events.Unmarshaller
// fog: the broker of the gateway, e.g. mqtt.NewMemory() in tests
Broker mqtt.Broker
// cloud: the broker the gateways reach (SYNC-04), e.g. mqtt.NewMemory() in tests
SyncBroker mqtt.Broker
// cloud: the hubs, which name the owners of networks (FOG-11); device-repository if not given
Hubs devicerepositoryclient.Interface
// fog: the owner of the network of the gateway (FOG-11); the cert-manager of the cloud proxy if not given
NetworkOwner fogsync.NetworkOwner
}
Dependencies replace connections to other services, e.g. in tests.
type EventDependencies ¶
type EventDependencies struct {
Unmarshaller events.Unmarshaller
Consumer events.Consumer
}
EventDependencies replace the unmarshalling and the Kafka consumer of the event role in tests.
type EventServer ¶
type EventServer struct {
Store *store.Store
Engine *engine.Engine
Worker *events.Worker
Metrics *Metrics
// contains filtered or unexported fields
}
EventServer is the event role: it evaluates device and import data and correlates events in the process, against the same database as the engine role (section 10).
func NewEventServer ¶
func NewEventServer(ctx context.Context, config configuration.Config, logger *slog.Logger, deps EventDependencies) (*EventServer, error)
func (*EventServer) Close ¶
func (this *EventServer) Close() error
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics exposes Prometheus metrics of the engine (OPS-05, LONG-13, LONG-14).
func NewMetrics ¶
NewMetrics registers the metrics; stalledAfter is the time without element change after which a running instance counts as stalled.
func (*Metrics) CommandSent ¶
CommandSent counts a device command per owner and deployment (TASK-12).
func (*Metrics) Correlation ¶
func (*Metrics) DeprecatedRequest ¶
DeprecatedRequest counts a request to a route of the deprecated/ layer (API-03).
func (*Metrics) InstanceEnded ¶
func (this *Metrics) InstanceEnded(namespace, deploymentId, owner string, state model.InstanceState)
func (*Metrics) InstanceStarted ¶
func (*Metrics) MarshallingLatency ¶
func (*Metrics) Run ¶
func (this *Metrics) Run(ctx context.Context, s *store.Store, interval time.Duration, logger *slog.Logger)
Run collects the gauges periodically until ctx is done.
func (*Metrics) Task ¶
func (this *Metrics) Task(taskType string, result string, namespace string, owner string, duration time.Duration)
Task counts a task execution and its time per owner, so that the cost of task execution can be shared by user (SNRGY-3077). The histogram has no owner label: per owner it would hold a series per bucket.
func (*Metrics) TimerDelay ¶
type Server ¶
type Server struct {
Store *store.Store
Engine *engine.Engine
Controller *controller.Controller
Handler http.Handler
Namespaces *namespaces.Registry
Permissions *permissions.Service
Metrics *Metrics
Live *debug.Hub
// removes the resources of deleted modules (SMS-06)
ModuleRemover *modules.Remover
// module task types and health checks (TASK-20 to TASK-29)
Modules *modules.Runtime
// nil if device commands are not configured
DeviceCommands *devicecommand.Type
// fog: the broker of the gateway and the event worker in the process (FOG-01, FOG-06)
Broker mqtt.Broker
Events *events.Worker
// fog: reports the connection state of devices to Events
Connections *events.DeviceManagerSource
// fog: the synchronisation with the cloud (SYNC-09)
Sync *fogsync.Gateway
// cloud: the synchronisation with gateways (SYNC-09)
Networks *fogsync.Cloud
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, config configuration.Config, logger *slog.Logger, deps Dependencies) (*Server, error)
New opens the store, applies migrations, loads the namespaces and builds engine, controller and handler of the engine role. Nothing runs yet; see Run.
func (*Server) HandleDeviceGroupMessage ¶ added in v0.39.0
HandleDeviceGroupMessage reacts to a device group that device-repository wrote or deleted: the event descriptions of deployments that select it change (DEP-08), and the watches of the group are checked (SNRGY-5132). An error repeats the message.
func (*Server) HandleDeviceMessage ¶ added in v0.39.0
HandleDeviceMessage reacts to a device that device-repository deleted: the watches of the device groups it was in are checked, since the groups keep it without an announcement of their own (SNRGY-5132). An error repeats the message.