workflow_service

package
v0.0.0-...-ba64992 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func CheckWorkflowName

func CheckWorkflowName(name string) bool

Types

type DigestData

type DigestData struct {
	EventIds []primitive.ObjectID `bson:"eventIds"`
}

type ErrNotExistsWorkflow

type ErrNotExistsWorkflow struct {
	Name string
}

func (*ErrNotExistsWorkflow) Error

func (e *ErrNotExistsWorkflow) Error() string

type EventDocument

type EventDocument struct {
	Id               primitive.ObjectID   `bson:"_id,omitempty"`
	Tenant           api_model.Tenant     `bson:"tenant"`
	Subscriber       api_model.Subscriber `bson:"subscriber"`
	WorkflowName     string               `bson:"workflowName"`
	WorkflowRevision int64                `bson:"workflowRevision"`
	EventType        EventType            `bson:"eventType"`
	NextAfterAt      time.Time            `bson:"nextAfterAt"`
	Finished         bool                 `bson:"finished"`

	// Data and FlowState is available when EventType == EventTypeTrigger
	Data      bsoncore.Document `bson:"data,omitempty"`
	FlowState []FlowState       `bson:"flowState"`
	FlowError []*string         `bson:"flowError"`

	DigestData *DigestData `bson:"digestData,omitempty"`
}

func (*EventDocument) DataFrom

func (d *EventDocument) DataFrom(data interface{}) error

func (*EventDocument) GetId

func (d *EventDocument) GetId() string

func (*EventDocument) ToBson

func (d *EventDocument) ToBson() (bson.M, error)

func (*EventDocument) ToBsonForMeta

func (d *EventDocument) ToBsonForMeta() (bson.M, error)

type EventType

type EventType string
const (
	EventTypeTrigger EventType = "trigger"
	EventTypeDigest  EventType = "digest"
)

type FlowState

type FlowState int
const (
	FlowStateWaiting   FlowState = 0
	FlowStateProcessed FlowState = 1
	FlowStateError     FlowState = 2
)

type TriggerParams

type TriggerParams struct {
	Name       string               `json:"name"`
	Tenant     api_model.Tenant     `json:"tenant"`
	Subscriber api_model.Subscriber `json:"subscriber"`
	Event      map[string]any       `json:"event"`
}

type WorkflowDocument

type WorkflowDocument struct {
	Id       primitive.ObjectID            `bson:"_id,omitempty" json:"_id,omitempty"`
	Name     string                        `bson:"name" json:"name"`
	Revision int64                         `bson:"revision" json:"revision"`
	Flow     []*api_model.WorkflowFlowItem `bson:"flow" json:"flow"`
}

func (*WorkflowDocument) GetId

func (d *WorkflowDocument) GetId() string

func (*WorkflowDocument) ToBson

func (d *WorkflowDocument) ToBson() (bson.M, error)

type WorkflowService

type WorkflowService interface {
	Start(appCtx context.Context, mongoDatabase *mongo.Database, brokerClient taskqueue.Client, leaderElection *mongo_leader.LeaderElection) error
	Trigger(params *TriggerParams) (eventId string, err error)
	CreateWorkflow(doc *WorkflowDocument) (*WorkflowDocument, error)
	GetWorkflow(name string) (*WorkflowDocument, error)
}

func New

Jump to

Keyboard shortcuts

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