migrate

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 35 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package migrate moves the data of the Camunda based services into the engine (MIG-01 to MIG-09). It reads the databases of the old services and the REST API of Camunda directly (decided for M7) and writes through the controller and the store of the engine.

A run is a dry run unless Apply is set. It only creates what is missing, so it can run again after a partial failure; ids are kept, and where a new id is needed it is derived from the old one, so that a second run finds what the first one created. The report lists per step what was migrated, what existed already, what needs a decision and what failed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(args []string, stdout io.Writer, stderr io.Writer) int

Main runs the subcommand migrate; the engine is configured as for serving, the sources by flags and, for secrets, by environment variables. It returns the exit code: 0 complete, 1 partial, 2 not run.

Types

type Camunda

type Camunda struct {
	// base URLs ending in /engine-rest
	Urls     []string
	User     string
	Password string
	Http     *http.Client
}

Camunda reads deployments and running instances through the REST API of Camunda engines, e.g. the shards of the process engine; the API needs basic auth.

func (*Camunda) CamundaDeployments

func (this *Camunda) CamundaDeployments(ctx context.Context) ([]CamundaDeployment, error)

CamundaDeployments lists the deployments of every engine with their first process definition and its BPMN; deployments without definition, e.g. of forms only, are left out

func (*Camunda) RunningInstances

func (this *Camunda) RunningInstances(ctx context.Context, d CamundaDeployment) ([]CamundaInstance, error)

RunningInstances reads the running instances of a deployment with their current variables and, from the history, their start time

type CamundaDeployment

type CamundaDeployment struct {
	Engine       string
	Id           string
	Name         string
	Source       string
	TenantId     string
	Time         time.Time
	DefinitionId string
	// deplid_<vid with _> for deployments of process-deployment, the process id otherwise
	Key  string
	Bpmn string
	// switched off through camunda-engine-wrapper v1.1.0, which suspends the definition
	Suspended bool
}

CamundaDeployment is a deployment in a Camunda engine with its process definition.

type CamundaInstance

type CamundaInstance struct {
	Id           string
	BusinessKey  string
	TenantId     string
	DefinitionId string
	Variables    map[string]any
	// from the history of Camunda; zero if it keeps none
	StartTime time.Time
}

CamundaInstance is a running process instance with its current variables.

type Design

type Design struct {
	Id          string
	UserId      string
	Name        string
	Description string
	BpmnXml     string
	SvgXml      string
	UpdatedAt   int64
}

Design is a design of smart-service-repository.

type FogDeployment

type FogDeployment struct {
	NetworkId           string
	CamundaDeploymentId string
	Deployment          models.Deployment
}

FogDeployment is a deployment of a gateway as process-sync keeps its metadata; the id of the deployment model is the platform id.

type FogStart

type FogStart struct {
	NetworkId    string
	BusinessKey  string
	DeploymentId string
	Parameters   map[string]any
}

FogStart is a start process-sync watches over (warden); the deployment id may be the platform id or the Camunda id of the gateway.

type InstanceVariable

type InstanceVariable struct {
	InstanceId string
	Name       string
	Value      any
}

type IoValue

type IoValue struct {
	UserId       string
	Key          string
	Value        any
	DefinitionId string
	InstanceId   string
	Timestamp    int64
}

IoValue is a value of process-io; definition and instance are those of Camunda.

type Item

type Item struct {
	Step    string `json:"step"`
	Kind    string `json:"kind"`
	Id      string `json:"id"`
	Owner   string `json:"owner,omitempty"`
	Status  Status `json:"status"`
	Message string `json:"message,omitempty"`
}

type Module

type Module struct {
	Id         string
	UserId     string
	InstanceId string
	Type       string
	Data       map[string]any
	Keys       []string
	DeleteUrl  string
	DeleteUser string
	Error      string
	LastUpdate int64
}

type Mongo

type Mongo struct {
	// contains filtered or unexported fields
}

Mongo reads the collections of the old services. The services wrote with the default codec of the MongoDB driver, which stores a field without bson tag under its lower-cased Go name and an embedded struct without inline as a sub-document. The documents here are decoded into structs with the same field names, so that they read back exactly as written.

func OpenMongo

func OpenMongo(ctx context.Context, url string, databases MongoDatabases) (*Mongo, error)

func (*Mongo) Close

func (this *Mongo) Close(ctx context.Context) error

func (*Mongo) Designs

func (this *Mongo) Designs(ctx context.Context) ([]Design, error)

func (*Mongo) FogDeployments

func (this *Mongo) FogDeployments(ctx context.Context) ([]FogDeployment, error)

func (*Mongo) FogStarts

func (this *Mongo) FogStarts(ctx context.Context) ([]FogStart, error)

func (*Mongo) IoValues

func (this *Mongo) IoValues(ctx context.Context) ([]IoValue, error)

func (*Mongo) Modules

func (this *Mongo) Modules(ctx context.Context) ([]Module, error)

func (*Mongo) ProcessDeployments

func (this *Mongo) ProcessDeployments(ctx context.Context) ([]ProcessDeployment, error)

func (*Mongo) ProcessModels

func (this *Mongo) ProcessModels(ctx context.Context) ([]ProcessModel, error)

func (*Mongo) Releases

func (this *Mongo) Releases(ctx context.Context) ([]Release, error)

Releases lists the finished releases; those marked as deleted or unfinished are left out

func (*Mongo) Schedules

func (this *Mongo) Schedules(ctx context.Context) ([]Schedule, error)

func (*Mongo) SmartServiceInstances

func (this *Mongo) SmartServiceInstances(ctx context.Context) ([]SmartServiceInstance, error)

SmartServiceInstances lists the instances; those being deleted are left out

func (*Mongo) SmartServiceVariables

func (this *Mongo) SmartServiceVariables(ctx context.Context) ([]InstanceVariable, error)

type MongoDatabases

type MongoDatabases struct {
	ProcessModels       string
	ProcessDeployments  string
	Scheduler           string
	SchedulerCollection string
	Io                  string
	SmartServices       string
	ProcessSync         string
}

MongoDatabases names the databases of the old services; the defaults are those of the platform since the move to the central MongoDB.

func DefaultMongoDatabases

func DefaultMongoDatabases() MongoDatabases

type Namespaces

type Namespaces interface {
	Get(name string) (model.Namespace, bool)
}

Namespaces knows the namespaces of the engine.

type OldServices

type OldServices struct {
	*Mongo
	*Camunda
	PermissionsV2
}

OldServices are the sources of a migration on the platform: the MongoDB of the services, the Camunda engines and permissions-v2.

type Options

type Options struct {
	// without Apply nothing is written
	Apply bool
	// deployments that exist only in Camunda and are to be migrated, by Camunda deployment id;
	// all others are listed for a decision (MIG-03)
	CamundaOnly map[string]bool
	// owners for resources whose owner is empty or invalid, e.g. releases with the creator
	// placeholder-for-invalid-data (MIG-09)
	Owners map[string]string
	// running instances are not restarted, only listed (MIG-02)
	NoRestart bool
}

Options steer a run.

type Parameter

type Parameter struct {
	Id    string
	Value any
}

type PermissionsV2

type PermissionsV2 struct {
	Client permclient.Client
	Token  func() (string, error)
}

PermissionsV2 reads and writes rights with an admin token, for the old topics and the topics of the namespaces alike.

func (PermissionsV2) Rights

func (PermissionsV2) SetRights

func (this PermissionsV2) SetRights(ctx context.Context, topic string, id string, permissions permmodel.ResourcePermissions) error

type ProcessDeployment

type ProcessDeployment struct {
	Id         string
	Owner      string
	Source     string
	Deployment models.Deployment
}

ProcessDeployment is a deployment of process-deployment; its id is the vid of the engine wrapper and the deployment id in the engine.

type ProcessModel

type ProcessModel struct {
	Id              string
	Name            string
	Owner           string
	BpmnXml         string
	SvgXml          string
	Description     string
	Publish         bool
	PublishDate     string
	Date            int64
	LastUpdatedUnix int64
}

ProcessModel is a model of process-model-repository.

type Release

type Release struct {
	Id          string
	DesignId    string
	Name        string
	Description string
	Creator     string
	BpmnXml     string
	SvgXml      string
	CreatedAt   int64
}

Release is a release of smart-service-repository with the BPMN of its design.

type Report

type Report struct {
	Items []Item `json:"items"`
}

func Run

func Run(ctx context.Context, options Options, sources Sources, target *Target) *Report

Run migrates step by step; a step that cannot read its source fails as a whole, the next steps run nevertheless.

func (*Report) Count

func (this *Report) Count(status Status) int

func (*Report) ExitCode

func (this *Report) ExitCode() int

ExitCode is 0 for a complete run, 1 if anything needs a decision or failed; findings of the model rewrite do not count, an unsupported part makes its deployment manual

func (*Report) Write

func (this *Report) Write(w io.Writer)

Write prints the report: a summary per step and kind, then every item that is not done and the rewritten parts and those to check of the models; the unsupported ones are named by the item of their deployment

type Rights

type Rights interface {
	Rights(ctx context.Context, topic string, id string) (permmodel.ResourcePermissions, bool, error)
	SetRights(ctx context.Context, topic string, id string, permissions permmodel.ResourcePermissions) error
}

Rights reads and writes resources of permissions-v2 as admin.

type Schedule

type Schedule struct {
	Id           string
	User         string
	Cron         string
	DeploymentId string
	Alias        string
	Disabled     bool
	CreatedBy    string
}

type SmartServiceInstance

type SmartServiceInstance struct {
	Id          string
	UserId      string
	ReleaseId   string
	Name        string
	Description string
	Parameters  []Parameter
	Ready       bool
	Error       string
	CreatedAt   int64
	UpdatedAt   int64
}

SmartServiceInstance is an instance of smart-service-repository; ready means its setup process ended in Camunda.

type Sources

type Sources interface {
	Designs(ctx context.Context) ([]Design, error)
	Releases(ctx context.Context) ([]Release, error)
	SmartServiceInstances(ctx context.Context) ([]SmartServiceInstance, error)
	Modules(ctx context.Context) ([]Module, error)
	SmartServiceVariables(ctx context.Context) ([]InstanceVariable, error)
	FogDeployments(ctx context.Context) ([]FogDeployment, error)
	FogStarts(ctx context.Context) ([]FogStart, error)
	ProcessModels(ctx context.Context) ([]ProcessModel, error)
	ProcessDeployments(ctx context.Context) ([]ProcessDeployment, error)
	Schedules(ctx context.Context) ([]Schedule, error)
	IoValues(ctx context.Context) ([]IoValue, error)
	// the Camunda engines of the processes namespace, all shards
	CamundaDeployments(ctx context.Context) ([]CamundaDeployment, error)
	RunningInstances(ctx context.Context, d CamundaDeployment) ([]CamundaInstance, error)
	// rights in permissions-v2
	Rights(ctx context.Context, topic string, id string) (permmodel.ResourcePermissions, bool, error)
}

Sources are the databases of the old services.

type Status

type Status string
const (
	Migrated Status = "migrated"
	// would be migrated in a dry run
	Planned  Status = "planned"
	Existing Status = "existing"
	// needs a decision or a manual step
	Manual Status = "manual"
	// left out on purpose, e.g. a deleted resource
	Skipped Status = "skipped"
	Failed  Status = "failed"
)
const (
	Rewritten   Status = "rewritten"
	Check       Status = "check"
	Unsupported Status = "unsupported"
)

Findings of the model rewrite of a deployment (MIG-04), as items of kind model; the item of the deployment carries its outcome.

type Target

type Target struct {
	Store      *store.Store
	Engine     *engine.Engine
	Controller *controller.Controller
	Namespaces Namespaces
	// an admin token, fetched per call since a migration may outlast a token
	AdminToken func() (string, error)
	// nil leaves rights alone, e.g. without permissions-v2
	Rights Rights
}

Target is the engine the data goes into. Writes go through the controller with an admin token, so that deployments are activated and instances started as by the API; resources the API creates with new ids (models, schedules, IO values) go into the store with their ids.

Directories

Path Synopsis
Package legacyio takes the values of process-io-worker on a gateway into the engine once, when the process module is updated and the old Postgres volume is still there (MIG-06).
Package legacyio takes the values of process-io-worker on a gateway into the engine once, when the process module is updated and the old Postgres volume is still there (MIG-06).
Package rewrite turns models written for Camunda 7 into the model format of this engine (MIG-04): JUEL becomes JavaScript, Groovy logging becomes log, external task topics become task types, the http-connector becomes a notification or an HTTP call, and message names with expressions become senergy:messageName.
Package rewrite turns models written for Camunda 7 into the model format of this engine (MIG-04): JUEL becomes JavaScript, Groovy logging becomes log, external task topics become task types, the http-connector becomes a notification or an HTTP call, and message names with expressions become senergy:messageName.

Jump to

Keyboard shortcuts

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