Documentation
¶
Overview ¶
Package modules runs the module task types of smart services and other namespaces (TASK-20 to TASK-29) and keeps their resources: removal through the outbox and health checks.
Index ¶
- Constants
- func Delete(ctx context.Context, client *http.Client, userToken auth.UserTokenSource, ...) error
- func UsedResources(process *bpmn.Process) model.UsedResources
- type Check
- type ExportDatabase
- type ExportInstance
- type ExportValue
- type FilterCriteria
- type FlowCell
- type GenericHttp
- type Handler
- type ImportConfig
- type ImportInstance
- type InputTopic
- type Maintenance
- type Mapping
- type Namespaces
- type NodeConfig
- type NodeInput
- type NodeValue
- type Operator
- type Pipeline
- type PipelineNode
- type PipelineRequest
- type Processes
- type Remover
- type Resources
- type Runtime
- func (this *Runtime) AddCheck(moduleType string, check Check)
- func (this *Runtime) AddProcessModules(processes Processes, namespaces Namespaces)
- func (this *Runtime) AddWatcher(maintenance Maintenance, generic GenericHttp, settings WatcherSettings)
- func (this *Runtime) CheckModules(ctx context.Context, interval time.Duration) error
- func (this *Runtime) CheckResources(ctx context.Context) error
- func (this *Runtime) CheckWatches(ctx context.Context) error
- func (this *Runtime) Register(e *engine.Engine, settings Settings)
- func (this *Runtime) RunHealthChecks(ctx context.Context, interval time.Duration)
- func (this *Runtime) RunResourceChecks(ctx context.Context, cycle time.Duration)
- func (this *Runtime) RunWatches(ctx context.Context, tick time.Duration)
- func (this *Runtime) SetAdminToken(token auth.TokenSource)
- type ServingRequest
- type ServingRequestValue
- type Settings
- type Task
- type WatcherSettings
Constants ¶
const ( TypeProcessDeployment = "process_deployment" TypeProcessDeploymentStart = "process_deployment_start" )
const ( TypeInfo = "info" TypeImport = "import" TypeExport = "export" TypeAnalytics = "analytics" TypeDeviceRepository = "device_repository" )
Task types of the former module workers (TASK-22 to TASK-26).
const TypeWatcher = "watcher"
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(ctx context.Context, client *http.Client, userToken auth.UserTokenSource, info model.ModuleDeleteInfo) error
Delete calls the delete URL of a module with the token of its user; 2xx and 404 count as removed, as with the module workers.
func UsedResources ¶
func UsedResources(process *bpmn.Process) model.UsedResources
UsedResources reads the process models, flows and import types the module tasks of a process name as literal text, as smart-service-repository indexes its releases: an id in an expression or a script is not known before the task runs (SMS-15).
Types ¶
type Check ¶
Check examines the resource of a module. A non-empty problem becomes the module error; an error means the check itself failed and leaves the module as it is.
type ExportDatabase ¶
type ExportInstance ¶
type ExportInstance struct {
ID uuid.UUID
Name string
Description string
EntityName string
ServiceName string
Topic string
ApplicationId uuid.UUID
Database string
Measurement string
Filter string
FilterType string
TimePath string
TimePrecision *string
UserId string
Generated bool
RancherServiceId string
Offset string
ExportDatabaseID string
ExportDatabase ExportDatabase
TimestampFormat string
Values []ExportValue
CreatedAt time.Time
UpdatedAt time.Time
}
ExportInstance is the export as serving answers it; the module keeps it under "export" with the field names of serving.
type ExportValue ¶
type FilterCriteria ¶
type FilterCriteria struct {
Interaction string `json:"interaction"`
FunctionId string `json:"function_id"`
DeviceClassId string `json:"device_class_id"`
// Deprecated: use AspectIds; AspectId is an alias for an AspectIds list with a single element.
AspectId string `json:"aspect_id"`
AspectIds []string `json:"aspect_ids,omitempty"`
}
FilterCriteria selects services and paths of devices for an input port.
type FlowCell ¶
type FlowCell struct {
Id string `json:"id"`
InPorts []string `json:"inPorts,omitempty"`
Config []struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
} `json:"config,omitempty"`
}
FlowCell is an operator of a flow with its input ports and configuration
type GenericHttp ¶
GenericHttp sends requests from models under the HTTP policy of a namespace (NS-04).
type Handler ¶
type Handler interface {
Do(ctx context.Context, task Task) (modules []model.Module, outputs map[string]any, err error)
}
Handler implements a module task type. Modules it returns become effects of the task; the runtime removes new ones again if the engine cannot apply the result.
type ImportConfig ¶
type ImportInstance ¶
type ImportInstance struct {
Id string `json:"id"`
Name string `json:"name"`
ImportTypeId string `json:"import_type_id"`
Image string `json:"image"`
KafkaTopic string `json:"kafka_topic"`
Configs []ImportConfig `json:"configs"`
Restart *bool `json:"restart"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Generated bool `json:"generated"`
}
ImportInstance is the import as import-deploy answers it; the module keeps it under "import".
type InputTopic ¶
type Maintenance ¶
type Maintenance interface {
StartMaintenanceInternal(ctx context.Context, id string, procedure string, variables map[string]any) (model.Instance, error)
}
Maintenance starts maintenance procedures without a caller (SMS-13).
type Namespaces ¶
Namespaces gives the referenced namespaces of the namespace of an instance (NS-08).
type NodeConfig ¶
type Operator ¶
type Operator struct {
Id string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
ImageId string `json:"imageId,omitempty"`
DeploymentType string `json:"deploymentType,omitempty"`
OperatorId string `json:"operatorId,omitempty"`
Config map[string]string `json:"config,omitempty"`
InputTopics []InputTopic
}
type Pipeline ¶
type Pipeline struct {
Id uuid.UUID `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Operators []Operator `json:"operators,omitempty"`
}
Pipeline is the answer of flow-engine; the module keeps it under "pipeline".
type PipelineNode ¶
type PipelineNode struct {
NodeId string `json:"nodeId,omitempty"`
Inputs []NodeInput `json:"inputs,omitempty"`
Config []NodeConfig `json:"config,omitempty"`
PersistData bool `json:"persistData,omitempty"`
}
type PipelineRequest ¶
type PipelineRequest struct {
Id string `json:"id,omitempty"`
FlowId string `json:"flowId,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
WindowTime int `json:"windowTime,omitempty"`
ConsumeAllMessages bool `json:"consumeAllMessages,omitempty"`
MergeStrategy string `json:"mergeStrategy,omitempty"`
Nodes []PipelineNode `json:"nodes,omitempty"`
}
type Processes ¶
type Processes interface {
GetModel(ctx context.Context, token string, namespace string, id string) (model.Model, error)
GetModelVersion(ctx context.Context, token string, namespace string, id string, version int) (model.ModelVersion, error)
CreateDeployment(ctx context.Context, token string, namespace string, input model.DeploymentInput) (model.Deployment, error)
PutDeployment(ctx context.Context, token string, namespace string, id string, input model.DeploymentInput) (model.Deployment, error)
StartInstance(ctx context.Context, token string, namespace string, input model.StartInstanceInput) (model.Instance, error)
// the gateways the user may read (SYNC-12)
ListNetworks(ctx context.Context, token string) ([]model.Network, error)
// removes the deployments and instances these modules create (SMS-06)
Resources
}
Processes is the part of the engine API the process modules use, with the owner's token.
type Remover ¶
type Remover struct {
// contains filtered or unexported fields
}
Remover removes the resources of deleted modules from the outbox, with growing pauses between attempts, so that nothing is left behind when a service is down (SMS-06).
func NewRemover ¶
func (*Remover) SetImportDeployUrl ¶ added in v0.10.7
SetImportDeployUrl sends the removal of imports the module worker created to import-deploy directly. The worker deleted them through Kong, and the migration kept that URL (MIG-01); Kong denies the client of the engine there, because Ladon has no policy for it (SNRGY-5025).
func (*Remover) SetResources ¶
SetResources removes the resources of the engine through the controller, so that those of gateways are deleted there too.
type Resources ¶
type Resources interface {
RemoveResource(ctx context.Context, ref model.ResourceRef) error
}
Resources removes the deployments, instances and watches of the engine that modules refer to. The controller deletes those of a gateway there as well, as through the API (SMS-12).
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime runs module handlers like the module workers did: string inputs are rendered as templates against the variables, prescripts and postscripts run with the script API of the worker library, and modules and variable changes become effects of the task (TASK-28).
func NewRuntime ¶
func NewRuntime(s *store.Store, settings Settings, tokens auth.UserTokenSource, logger *slog.Logger) *Runtime
NewRuntime creates the runtime; tokens gives the tokens of owners, e.g. the token exchange.
func (*Runtime) AddProcessModules ¶
func (this *Runtime) AddProcessModules(processes Processes, namespaces Namespaces)
AddProcessModules registers process_deployment (TASK-20) and process_deployment_start (TASK-21).
func (*Runtime) AddWatcher ¶
func (this *Runtime) AddWatcher(maintenance Maintenance, generic GenericHttp, settings WatcherSettings)
AddWatcher registers the watcher task type (TASK-27): instead of an own database and API, the watches are rows of the engine, checked by every replica in turn.
func (*Runtime) CheckModules ¶
CheckModules checks the modules whose last check is older than interval.
func (*Runtime) CheckResources ¶
CheckResources checks every deployment version that is current or still has instances and names resources in its module tasks.
func (*Runtime) CheckWatches ¶
CheckWatches checks the due watches once.
func (*Runtime) Register ¶
Register makes the module task types available to an engine whose services are configured, so that a deploy reports a missing one instead of an incident later.
func (*Runtime) RunHealthChecks ¶
RunHealthChecks checks every module once per interval, like the module workers did (SMS-11).
func (*Runtime) RunResourceChecks ¶
RunResourceChecks checks the resources of all deployment versions every cycle; 0 does nothing.
func (*Runtime) RunWatches ¶
RunWatches checks due watches until ctx is done.
func (*Runtime) SetAdminToken ¶
func (this *Runtime) SetAdminToken(token auth.TokenSource)
SetAdminToken sets the token of the engine for the check of used resources.
type ServingRequest ¶
type ServingRequest struct {
FilterType string `json:"FilterType,omitempty" validate:"required"`
Filter string `json:"Filter,omitempty" validate:"required"`
Name string `json:"Name,omitempty" validate:"required"`
EntityName string `json:"EntityName,omitempty" validate:"required"`
ServiceName string `json:"ServiceName,omitempty" validate:"required"`
Description string `json:"Description,omitempty"`
Topic string `json:"Topic,omitempty" validate:"required"`
TimePath string `json:"TimePath,omitempty"`
TimePrecision string `json:"TimePrecision,omitempty"`
Generated bool `json:"generated,omitempty"`
Offset string `json:"Offset,omitempty" validate:"required"`
ForceUpdate bool `json:"ForceUpdate,omitempty"`
Values []ServingRequestValue `json:"Values,omitempty"`
ExportDatabaseID string `json:"ExportDatabaseID,omitempty"`
TimestampFormat string `json:"TimestampFormat,omitempty"`
}
ServingRequest asks serving for an export. Filter conventions: for operatorId the filter is "<pipeline>:<operator>" and the topic "analytics-<operator name>", for import_id the import id and its kafka topic.
type ServingRequestValue ¶
type Settings ¶
type Settings struct {
DeviceRepositoryUrl string
DeviceSelectionUrl string
DeviceManagerUrl string
FlowEngineUrl string
FlowParserUrl string
ImportDeployUrl string
ServingServiceUrl string
// repositories of flows and import types, asked whether used resources changed (SMS-15)
FlowRepoUrl string
ImportRepositoryUrl string
AnalyticsEnableMultiplePaths bool
AnalyticsDevicePathPrefix string
AnalyticsGroupPathPrefix string
AnalyticsImportPathPrefix string
AnalyticsRemoveImportPathRoot bool
DeviceGroupNamePrefix string
DeviceGroupAttributeOrigin string
InfoAdditionalModuleDataFields bool
}
Settings are the configuration values of the former module workers (TASK-29). The parameter prefixes are part of the model format and stay those of the workers: "<task type>.".
type Task ¶
type Task struct {
// the job; module ids are "<instance>.<job>", as "<process instance>.<task>" before
Id string
InstanceId string
RootInstanceId string
DeploymentId string
ElementId string
Namespace string
Owner string
Inputs map[string]any
}
Task is a module task as a handler sees it: the inputs after the templates were rendered.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package compat keeps the module task types compatible with the former smart service module workers (TASK-28): string inputs are templates over the instance variables, and prescript and postscript inputs run with the script API of smart-service-module-worker-lib, ported from that library.
|
Package compat keeps the module task types compatible with the former smart service module workers (TASK-28): string inputs are templates over the instance variables, and prescript and postscript inputs run with the script API of smart-service-module-worker-lib, ported from that library. |