wfmodel

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageTypeDataBatch             = 1
	MessageTypeShutown               = 101 // pass processor_id
	MessageTypeSetLoggingLevel       = 102 // pass processor_id and logging level
	MessageTypeCancelProcessInstance = 103 // Pass process id and process instance
)

Message types, payload depends on it

View Source
const DependencyNodeEventTableName string = "e"
View Source
const LogTsFormatQuoted = `"2006-01-02T15:04:05.000-0700"`
View Source
const PrintTableDelimiter = "/"
View Source
const TableNameBatchHistory = "wf_batch_history"
View Source
const TableNameNodeHistory = "wf_node_history"
View Source
const TableNameRunAffectedNodes = "wf_run_affected_nodes"
View Source
const TableNameRunCounter = "wf_run_counter"
View Source
const TableNameRunHistory = "wf_run_history"
View Source
const WfmodelNamespace string = "wfmodel"

Variables

This section is empty.

Functions

func BatchHistoryAllFields

func BatchHistoryAllFields() []string

func GetCreateTableCql

func GetCreateTableCql(t reflect.Type, keyspace string, tableName string) string

func GetObjectModelFieldFormats

func GetObjectModelFieldFormats(t reflect.Type) []string

GetObjectModelFieldFormats - helper to get formats for each field of an object model

func GetSpacedHeader

func GetSpacedHeader(n interface{}) string

GetSpacedHeader - prints formatted struct field names, uses reflection, shoud not be used in prod

func NewVarsFromDepCtx

func NewVarsFromDepCtx(runId int16, e DependencyNodeEvent) eval.VarValuesMap

func NodeHistoryAllFields

func NodeHistoryAllFields() []string

func ReadInt16FromRow

func ReadInt16FromRow(fieldName string, r map[string]interface{}) (int16, error)

func ReadInt64FromRow

func ReadInt64FromRow(fieldName string, r map[string]interface{}) (int64, error)

func ReadStringFromRow

func ReadStringFromRow(fieldName string, r map[string]interface{}) (string, error)

func ReadTimeFromRow

func ReadTimeFromRow(fieldName string, r map[string]interface{}) (time.Time, error)

func RunHistoryAllFields

func RunHistoryAllFields() []string

Types

type BatchHistory

type BatchHistory struct {
	Ts           time.Time           `header:"ts" format:"%-33v" column:"ts" type:"timestamp"`
	RunId        int16               `header:"run_id" format:"%6d" column:"run_id" type:"int" key:"true"`
	ScriptNode   string              `header:"script_node" format:"%20v" column:"script_node" type:"text" key:"true"`
	BatchIdx     int16               `header:"bnum" format:"%5v" column:"batch_idx" type:"int" key:"true"`
	BatchesTotal int16               `header:"tbtchs" format:"%6v" column:"batches_total" type:"int"`
	Status       NodeBatchStatusType `header:"sts" format:"%3v" column:"status" type:"tinyint" key:"true"`
	FirstToken   int64               `header:"ftoken" format:"%21v" column:"first_token" type:"bigint"`
	LastToken    int64               `header:"ltoken" format:"%21v" column:"last_token" type:"bigint"`
	Comment      string              `header:"comment" format:"%v" column:"comment" type:"text"`
}

Object model with tags that allow to create cql CREATE TABLE queries and to print object

func NewBatchHistoryFromMap

func NewBatchHistoryFromMap(r map[string]interface{}, fields []string) (*BatchHistory, error)

func (BatchHistory) ToSpacedString

func (n BatchHistory) ToSpacedString() string

ToSpacedString - prints formatted field values, uses reflection, shoud not be used in prod

type DependencyNodeEvent

type DependencyNodeEvent struct {
	RunId         int16
	RunIsCurrent  bool
	RunStartTs    time.Time
	RunStatus     RunStatusType
	RunStatusTs   time.Time
	NodeIsStarted bool
	NodeStartTs   time.Time
	NodeStatus    NodeBatchStatusType
	NodeStatusTs  time.Time
	SortKey       string
}

func (*DependencyNodeEvent) ToString

func (e *DependencyNodeEvent) ToString() string

func (*DependencyNodeEvent) ToVars

type DependencyNodeEvents

type DependencyNodeEvents []DependencyNodeEvent

func (DependencyNodeEvents) ToString

func (events DependencyNodeEvents) ToString() string

type Message

type Message struct {
	Ts          int64       `json:"ts"`
	MessageType int         `json:"message_type"`
	Payload     interface{} `json:"payload"` // This depends on MessageType
}

Message - carries data and signals to processors/nodes 1. No version support. Premature optimization is the root of all evil. 2. Used for data transfer and for control signals. 3. For faster de/serialization, consider custom parser not involving reflection 4. Timestamps are int (not uint) because Unix epoch is int

func (*Message) Deserialize

func (msg *Message) Deserialize(jsonBytes []byte) error

func (Message) Serialize

func (msg Message) Serialize() ([]byte, error)

func (Message) ToString

func (msg Message) ToString() string

type MessagePayloadComment

type MessagePayloadComment struct {
	Comment string `json:"comment"`
}

MessagePayloadComment - generic paylod Comment - unstructured, can be anything, like information about the sender of the signal

type MessagePayloadDataBatch

type MessagePayloadDataBatch struct {
	ScriptURI       string `json:"script_uri"`
	ScriptParamsURI string `json:"script_params_uri"`
	DataKeyspace    string `json:"data_keyspace"` // Instance/process id
	RunId           int16  `json:"run_id"`
	TargetNodeName  string `json:"target_node"`
	FirstToken      int64  `json:"first_token"`
	LastToken       int64  `json:"last_token"`
	BatchIdx        int16  `json:"batch_idx"`
	BatchesTotal    int16  `json:"batches_total"`
}

func (*MessagePayloadDataBatch) Deserialize

func (dc *MessagePayloadDataBatch) Deserialize(jsonBytes []byte) error

func (*MessagePayloadDataBatch) FullBatchId

func (dc *MessagePayloadDataBatch) FullBatchId() string

func (MessagePayloadDataBatch) Serialize

func (dc MessagePayloadDataBatch) Serialize() ([]byte, error)

func (*MessagePayloadDataBatch) ToString

func (dc *MessagePayloadDataBatch) ToString() string

type NodeBatchStatusType

type NodeBatchStatusType int8
const (
	NodeBatchNone            NodeBatchStatusType = 0
	NodeBatchStart           NodeBatchStatusType = 1
	NodeBatchSuccess         NodeBatchStatusType = 2
	NodeBatchFail            NodeBatchStatusType = 3 // Biz logicerror or data tble (not WF) error
	NodeBatchRunStopReceived NodeBatchStatusType = 104
)

In priority order

const (
	NodehNone           NodeBatchStatusType = 0
	NodeStart           NodeBatchStatusType = 1
	NodeSuccess         NodeBatchStatusType = 2
	NodeFail            NodeBatchStatusType = 3
	NodeRunStopReceived NodeBatchStatusType = 104
)

func ReadNodeBatchStatusFromRow

func ReadNodeBatchStatusFromRow(fieldName string, r map[string]interface{}) (NodeBatchStatusType, error)

func (NodeBatchStatusType) ToString

func (status NodeBatchStatusType) ToString() string

type NodeHistory

type NodeHistory struct {
	Ts         time.Time           `header:"ts" format:"%-33v" column:"ts" type:"timestamp"`
	RunId      int16               `header:"run_id" format:"%6d" column:"run_id" type:"int" key:"true"`
	ScriptNode string              `header:"script_node" format:"%20v" column:"script_node" type:"text" key:"true"`
	Status     NodeBatchStatusType `header:"sts" format:"%3v" column:"status" type:"tinyint" key:"true"`
	Comment    string              `header:"comment" format:"%v" column:"comment" type:"text"`
}

Object model with tags that allow to create cql CREATE TABLE queries and to print object

func NewNodeHistoryFromMap

func NewNodeHistoryFromMap(r map[string]interface{}, fields []string) (*NodeHistory, error)

func (NodeHistory) ToSpacedString

func (n NodeHistory) ToSpacedString() string

ToSpacedString - prints formatted field values, uses reflection, shoud not be used in prod

type NodeLifespan

type NodeLifespan struct {
	StartTs      time.Time
	LastStatus   NodeBatchStatusType
	LastStatusTs time.Time
}

func (NodeLifespan) ToString

func (ls NodeLifespan) ToString() string

type NodeLifespanMap

type NodeLifespanMap map[string]*NodeLifespan

func (NodeLifespanMap) ToString

func (m NodeLifespanMap) ToString() string

type NodeRunBatchStatusMap

type NodeRunBatchStatusMap map[string]RunBatchStatusMap

func (NodeRunBatchStatusMap) ToString

func (m NodeRunBatchStatusMap) ToString() string

type NodeStatusMap

type NodeStatusMap map[string]NodeBatchStatusType

func (NodeStatusMap) ToString

func (m NodeStatusMap) ToString() string

type NodeStatusType

type NodeStatusType int8

type RunAffectedNodes

type RunAffectedNodes struct {
	RunId         int16  `header:"run_id" format:"%6d" column:"run_id" type:"int" key:"true"`
	AffectedNodes string `header:"affected_nodes" format:"%20v" column:"affected_nodes" type:"text"`
}

Object model with tags that allow to create cql CREATE TABLE queries and to print object

func NewRunAffectedNodesFromMap

func NewRunAffectedNodesFromMap(r map[string]interface{}, fields []string) (*RunAffectedNodes, error)

func (RunAffectedNodes) ToSpacedString

func (n RunAffectedNodes) ToSpacedString() string

ToSpacedString - prints formatted field values, uses reflection, shoud not be used in prod

type RunBatchStatusMap

type RunBatchStatusMap map[int16]NodeBatchStatusType

func (RunBatchStatusMap) ToString

func (m RunBatchStatusMap) ToString() string

type RunCounter

type RunCounter struct {
	Keyspace int `header:"ks" format:"%20s" column:"ks" type:"text" key:"true"`
	LastRun  int `header:"lr" format:"%3d" column:"last_run" type:"int"`
}

Object model with tags that allow to create cql CREATE TABLE queries and to print object

type RunHistory

type RunHistory struct {
	Ts      time.Time     `header:"ts" format:"%-33v" column:"ts" type:"timestamp"`
	RunId   int16         `header:"run_id" format:"%6d" column:"run_id" type:"int" key:"true"`
	Status  RunStatusType `header:"sts" format:"%3v" column:"status" type:"tinyint" key:"true"`
	Comment string        `header:"comment" format:"%v" column:"comment" type:"text"`
}

Object model with tags that allow to create cql CREATE TABLE queries and to print object

func NewRunHistoryFromMap

func NewRunHistoryFromMap(r map[string]interface{}, fields []string) (*RunHistory, error)

func (RunHistory) ToSpacedString

func (n RunHistory) ToSpacedString() string

ToSpacedString - prints formatted field values, uses reflection, shoud not be used in prod

type RunLifespan

type RunLifespan struct {
	StartTs      time.Time
	LastStatus   RunStatusType
	LastStatusTs time.Time
}

func (RunLifespan) ToString

func (ls RunLifespan) ToString() string

type RunLifespanMap

type RunLifespanMap map[int16]*RunLifespan

func (RunLifespanMap) ToString

func (m RunLifespanMap) ToString() string

type RunNodeLifespanMap

type RunNodeLifespanMap map[int16]NodeLifespanMap

func (RunNodeLifespanMap) ToString

func (m RunNodeLifespanMap) ToString() string

type RunStartTsMap

type RunStartTsMap map[int16]time.Time

func (RunStartTsMap) ToString

func (m RunStartTsMap) ToString() string

type RunStatusMap

type RunStatusMap map[int16]RunStatusType

func (RunStatusMap) ToString

func (m RunStatusMap) ToString() string

type RunStatusType

type RunStatusType int8
const (
	RunNone     RunStatusType = 0
	RunStart    RunStatusType = 1
	RunComplete RunStatusType = 2
	RunStop     RunStatusType = 3
)

func ReadRunStatusFromRow

func ReadRunStatusFromRow(fieldName string, r map[string]interface{}) (RunStatusType, error)

func (RunStatusType) ToString

func (status RunStatusType) ToString() string

Jump to

Keyboard shortcuts

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