package protocol

import "fmt"

// RelationType 默认节点关系
type RelationType string

type RelationTypes []RelationType

func (a RelationType) String() string {
	return string(a)
}

func (a RelationTypes) ToStrArray() []string {
	var str []string
	for _, item := range a {
		str = append(str, item.String())
	}
	return str
}

const (
	Success RelationType = "Success" // 成功
	Failure RelationType = "Failure" // 失败
	Other   RelationType = "Other"   // 其他
	True    RelationType = "True"    // 真
	False   RelationType = "False"   // 假

	PostAttributes  RelationType = "Post attributes"  // 上报属性
	PostEvent       RelationType = "Post Event"       // 上报事件
	ConnectEvent    RelationType = "Connect Event"    // 接入
	DisconnectEvent RelationType = "Disconnect Event" // 断开
)

const (
	POST_ATTRIBUTES_REQUEST = "POST_ATTRIBUTES_REQUEST" // 属性上报消息
	POST_EVENT_REQUEST      = "POST_EVENT_REQUEST"      // 事件上报消息
	CONNECT_EVENT           = "CONNECT_EVENT"           // 接入事件
	DISCONNECT_EVENT        = "DISCONNECT_EVENT"        // 断开事件
)

// RuleNodeInfo rule node info for output
type RuleNodeInfo struct {
	RuleNodeId    string
	RuleChainName string
	RuleNodeName  string
}

func (r *RuleNodeInfo) String() string {
	return fmt.Sprintf("[RuleChain:%s|RuleNode:%s|RuleNodeId:%s]", r.RuleChainName, r.RuleNodeName, r.RuleNodeId)
}

type RuleNodeRelation struct {
	In           string
	Out          string
	RelationType RelationType
}
