package ruleEngine import ( "sparrow/pkg/entities" "sparrow/pkg/protocol" ) // RuleChainToRuleNodeMsg 规则链到规则节点的消息定义 type RuleChainToRuleNodeMsg struct { Message *protocol.Message Ctx Context FromRelationType string } func (r *RuleChainToRuleNodeMsg) GetMessageType() protocol.MsgType { return protocol.RULE_CHAIN_TO_RULE_MSG } // RuleChainToRuleChainMsg 规则链到另一个规则链的消息 type RuleChainToRuleChainMsg struct { TargetId string SourceId string FromRelationType string Message *protocol.Message } func (t *RuleChainToRuleChainMsg) GetMessageType() protocol.MsgType { return protocol.RULE_CHAIN_TO_RULE_CHAIN_MSG } // TransportToDeviceActorMsg 传输层到设备actor的消息定义 type TransportToDeviceActorMsg struct { Message *protocol.Message } func (t *TransportToDeviceActorMsg) GetMessageType() protocol.MsgType { return protocol.TRANSPORT_TO_DEVICE_ACTOR_MSG } // QueueToRuleEngineMsg 消息队列到规则引擎的消息定义 type QueueToRuleEngineMsg struct { TenantId string Message *protocol.Message RelationTypes []string FailureMessage error } func (q *QueueToRuleEngineMsg) GetMessageType() protocol.MsgType { return protocol.QUEUE_TO_RULE_ENGINE_MSG } type RuleNodeToRuleChanTellNextMsg struct { RuleNodeId string RelationTypes protocol.RelationTypes Message *protocol.Message FailureMessage error } func (r *RuleNodeToRuleChanTellNextMsg) GetMessageType() protocol.MsgType { return protocol.RULE_TO_RULE_CHAIN_TELL_NEXT_MSG } type RuleToSelfMsg struct { Message *protocol.Message } func (r *RuleToSelfMsg) GetMessageType() protocol.MsgType { return protocol.RULE_TO_SELF_MSG } type RuleToSelfErrorMsg struct { Message *protocol.Message Err error } func (r *RuleToSelfErrorMsg) GetMessageType() protocol.MsgType { return protocol.RULE_TO_SELF_ERROR_MSG } // AppInitMsg app 初始化消息 type AppInitMsg struct { } func (a *AppInitMsg) GetMessageType() protocol.MsgType { return protocol.APP_INIT_MSG } type ComponentLifecycleMsg struct { TenantId string EntityId entities.EntityId EventType ComponentLifecycleEvent } func (c *ComponentLifecycleMsg) GetRuleChainId() string { if c.EntityId.GetEntityType() == entities.RULE_CHAIN { return c.EntityId.GetId() } else { return "" } } func (c *ComponentLifecycleMsg) GetMessageType() protocol.MsgType { return protocol.COMPONENT_LIFE_CYCLE_MSG } // ComponentLifecycleEvent 组件节点生命周期 type ComponentLifecycleEvent string const ( CREATED ComponentLifecycleEvent = "CREATED" STARTED ComponentLifecycleEvent = "STARTED" ACTIVATED ComponentLifecycleEvent = "ACTIVATED" UPDATED ComponentLifecycleEvent = "UPDATED" STOPPED ComponentLifecycleEvent = "STOPPED" DELETED ComponentLifecycleEvent = "DELETED" ) // ComponentLifecycleState 生命周期状态 type ComponentLifecycleState int const ( ACTIVE ComponentLifecycleState = iota SUSPENDED )