rule

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const EOFMessage = "done"

Variables

View Source
var StateName = map[RunState]string{
	Stopped:       "stopped",
	Starting:      "starting",
	Running:       "running",
	Stopping:      "stopping",
	ScheduledStop: "stopped: waiting for next schedule.",
	StoppedByErr:  "stopped by error",
}

Functions

This section is empty.

Types

type ActionSignal

type ActionSignal int
const (
	ActionSignalStart ActionSignal = iota
	ActionSignalStop
	ActionSignalScheduledStart
	ActionSignalScheduledStop
)

type RunState

type RunState int
const (
	Stopped RunState = iota
	Starting
	Running
	Stopping
	ScheduledStop
	StoppedByErr
)

type State

type State struct {
	sync.RWMutex
	// Nearly constant, only change when update the Rule
	// It is used to construct topo
	Rule *def.Rule
	// contains filtered or unexported fields
}

State control the Rule RunState Created when loading from DB or creating. Deleted when Rule deleting May be accessed by multiple go routines, receiving concurrent request to change the RunState

func NewState

func NewState(rule *def.Rule, updateTriggerFunc func(string, bool)) *State

NewState provision a state instance only. Do not plan or run as before. If the Rule is not triggered, do not plan or run. When called by recover Rule, expect

func (*State) Delete

func (s *State) Delete() (err error)

func (*State) GetLastWill

func (s *State) GetLastWill() string

func (*State) GetMetrics

func (s *State) GetMetrics() ([]string, []any)

func (*State) GetStartTimestamp added in v2.2.0

func (s *State) GetStartTimestamp() time.Time

func (*State) GetState

func (s *State) GetState() RunState

func (*State) GetStatusMap

func (s *State) GetStatusMap() map[string]any

func (*State) GetStatusMessage

func (s *State) GetStatusMessage() string

GetStatusMessage return the current RunState of the Rule No set is provided, RunState are changed according to the action (start, stop)

func (*State) GetStreams

func (s *State) GetStreams() []string

func (*State) GetTopoGraph

func (s *State) GetTopoGraph() *def.PrintableTopo

func (*State) HasTopo added in v2.0.7

func (s *State) HasTopo() bool

func (*State) IsTraceEnabled

func (s *State) IsTraceEnabled() bool

func (*State) ResetStreamOffset

func (s *State) ResetStreamOffset(name string, input map[string]any) error

func (*State) ScheduleStart

func (s *State) ScheduleStart() error

func (*State) ScheduleStop

func (s *State) ScheduleStop()

func (*State) SetIsTraceEnabled

func (s *State) SetIsTraceEnabled(isEnabled bool, stra kctx.TraceStrategy) error

func (*State) Start

func (s *State) Start() error

Start run start or add the start action to queue By check state, it assures only one Start function is running at any time. (thread safe) regSchedule: whether need to handle scheduler. If call externally, set it to true

func (*State) Stop

func (s *State) Stop()

Stop run stop action or add the stop action to queue regSchedule: whether need to handle scheduler. If call externally, set it to true

func (*State) StopWithLastWill added in v2.2.0

func (s *State) StopWithLastWill(msg string)

func (*State) Validate

func (s *State) Validate() (*topo.Topo, error)

Validate tries to plan and return the planned topo and any errors Need to cancel the topo if it is of no use because the input/output channels are set Otherwise, the shared source may send to these channels and hang

func (*State) WithTopo

func (s *State) WithTopo(topo *topo.Topo) *State

Jump to

Keyboard shortcuts

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