2023-07-20 22:08:28 -06:00
|
|
|
package graphvent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
)
|
|
|
|
|
2023-07-26 00:18:11 -06:00
|
|
|
type GroupExt struct {
|
2023-09-13 16:27:55 -06:00
|
|
|
Members map[NodeID]string `gv:"members"`
|
2023-07-25 09:51:55 -06:00
|
|
|
}
|
|
|
|
|
2023-07-26 00:18:11 -06:00
|
|
|
func (ext *GroupExt) Type() ExtType {
|
|
|
|
return GroupExtType
|
2023-07-25 09:51:55 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
func (ext *GroupExt) MarshalBinary() ([]byte, error) {
|
2023-08-11 13:01:32 -06:00
|
|
|
return json.Marshal(ext)
|
2023-07-25 09:51:55 -06:00
|
|
|
}
|
|
|
|
|
2023-07-28 00:04:18 -06:00
|
|
|
func NewGroupExt(members map[NodeID]string) *GroupExt {
|
2023-07-26 11:56:10 -06:00
|
|
|
if members == nil {
|
2023-07-28 00:04:18 -06:00
|
|
|
members = map[NodeID]string{}
|
2023-07-26 11:56:10 -06:00
|
|
|
}
|
2023-07-28 00:04:18 -06:00
|
|
|
|
2023-07-26 11:56:10 -06:00
|
|
|
return &GroupExt{
|
|
|
|
Members: members,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-01 20:55:15 -06:00
|
|
|
func (ext *GroupExt) Deserialize(ctx *Context, data []byte) error {
|
2023-08-11 13:01:32 -06:00
|
|
|
ext.Members = map[NodeID]string{}
|
|
|
|
return json.Unmarshal(data, ext)
|
2023-07-26 00:18:11 -06:00
|
|
|
}
|
2023-07-25 09:51:55 -06:00
|
|
|
|
2023-08-08 14:00:17 -06:00
|
|
|
func (ext *GroupExt) Process(ctx *Context, node *Node, source NodeID, signal Signal) Messages {
|
2023-08-07 20:26:02 -06:00
|
|
|
return nil
|
2023-07-26 00:18:11 -06:00
|
|
|
}
|
2023-07-28 00:04:18 -06:00
|
|
|
|