state

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// statem runtime-status enumerates.
	StateRuntimeDetached int32 = 0
	StateRuntimeAttached int32 = 1

	// statem status enumerates.
	SMStatusActive   Status = "active"
	SMStatusInactive Status = "inactive"
	SMStatusDeleted  Status = "deleted"

	// reserved property field.
	ReservedFieldID         = "id"
	ReservedFieldType       = "type"
	ReservedFieldOwner      = "owner"
	ReservedFieldSource     = "source"
	ReservedFieldVersion    = "version"
	ReservedFieldConfigs    = "configs"
	ReservedFieldMappers    = "mappers"
	ReservedFieldLastTime   = "last_time"
	ReservedFieldTemplate   = "template"
	ReservedFieldProperties = "properties"
	ReservedFieldConfigFile = "config_file"
)

Variables

Functions

func GetPatchCodec

func GetPatchCodec() patchDataCodec

func NewManagerMock

func NewManagerMock() types.Manager

func SquashFields

func SquashFields(header map[string]string) map[string]string

Types

type APIHandler

type APIHandler func(context.Context, message.Context) ([]WatchKey, error)

type APIID

type APIID string
const (
	APICreateEntity        APIID = "core.apis.Entity.Create"
	APIUpdateEntity        APIID = "core.apis.Entity.Update"
	APIGetEntity           APIID = "core.apis.Entity.Get"
	APIDeleteEntity        APIID = "core.apis.Entity.Delete"
	APIUpdataEntityProps   APIID = "core.apis.Entity.Props.Update"
	APIPatchEntityProps    APIID = "core.apis.Entity.Props.Patch"
	APIGetEntityProps      APIID = "core.apis.Entity.Props.Get"
	APIUpdataEntityConfigs APIID = "core.apis.Entity.Configs.Update"
	APIPatchEntityConfigs  APIID = "core.apis.Entity.Configs.Patch"
	APIGetEntityConfigs    APIID = "core.apis.Entity.Configs.Get"
)

func (APIID) String

func (a APIID) String() string

type ItemsData

type ItemsData struct {
	ID           string   `json:"id"`
	Type         string   `json:"type"`
	Owner        string   `json:"owner"`
	Source       string   `json:"source"`
	PropertyKeys []string `json:"property_keys"`
}

type Machiner

type Machiner interface {
	// GetID return state machine id.
	GetID() string
	// GetEntity returns this.Entity.
	GetEntity() *dao.Entity
	// Context return state context.
	Context() *StateContext
	// OnMessage recv message from pubsub.
	Invoke(ctx context.Context, msgCtx message.Context) Result
	// Flush flush entity data.
	Flush(ctx context.Context) error
}

func NewState

func NewState(ctx context.Context, in *dao.Entity, dispatcher dispatch.Dispatcher, resourceManager types.ResourceManager, republisher MessageHandler) (Machiner, error)

NewState create an statem object.

type ManagerMock

type ManagerMock struct {
}

func (*ManagerMock) Resource

func (s *ManagerMock) Resource() types.ResourceManager

func (*ManagerMock) RouteMessage

func (s *ManagerMock) RouteMessage(ctx context.Context, e cloudevents.Event) error

func (*ManagerMock) SetRepublisher

func (s *ManagerMock) SetRepublisher(republisher types.Republisher)

func (*ManagerMock) Shutdown

func (s *ManagerMock) Shutdown() error

func (*ManagerMock) Start

func (s *ManagerMock) Start() error

type Mapper

type Mapper struct {
	ID          string `json:"id" msgpack:"id"`
	TQL         string `json:"tql" msgpack:"tql"`
	Name        string `json:"name" msgpack:"name"`
	Description string `json:"description" msgpack:"description"`
}

type MessageHandler

type MessageHandler = func(context.Context, message.Context) []WatchKey

type PatchData

type PatchData struct {
	Path     string      `json:"path"`
	Operator string      `json:"operator"`
	Value    interface{} `json:"value"`
}

type RawData

type RawData struct {
	ID        string `json:"id"`
	Type      string `json:"type"`
	Mark      string `json:"mark"`
	Path      string `json:"path"`
	Values    string `json:"values"`
	Timestamp int64  `json:"ts"` //nolint
}

type Result

type Result struct {
	Err    error
	Status Status
}

type State

type State struct {
	ID    string
	Props map[string]tdtl.Node
}

func (*State) Get

func (s *State) Get(path string) (tdtl.Node, error)

func (*State) Patch

func (s *State) Patch(op xjson.PatchOp, path string, value []byte) (tdtl.Node, error)

type StateContext

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

func (*StateContext) LoadEnvironments

func (ctx *StateContext) LoadEnvironments(env environment.ActorEnv)

type Status

type Status string
const (
	MCreated   Status = "Created"
	MDeleted   Status = "Deleted"
	MFailured  Status = "Failured"
	MCompleted Status = "Completed"
)

type WatchKey

type WatchKey = mapper.WatchKey

Jump to

Keyboard shortcuts

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