github.com/s7techlab/cckit@v0.10.5/state/mapping/event_instance.go (about) 1 package mapping 2 3 import ( 4 "github.com/s7techlab/cckit/state" 5 ) 6 7 type ( 8 EventInstance struct { 9 instance interface{} 10 eventMapper EventMapper 11 serializer state.Serializer 12 } 13 ) 14 15 func NewEventInstance(instance interface{}, eventMapper EventMapper, serializer state.Serializer) (*EventInstance, error) { 16 return &EventInstance{ 17 instance: instance, 18 eventMapper: eventMapper, 19 serializer: serializer, 20 }, nil 21 } 22 23 func (ei EventInstance) Name() (string, error) { 24 return ei.eventMapper.Name(ei.instance) 25 } 26 27 func (ei EventInstance) ToBytes() ([]byte, error) { 28 return ei.serializer.ToBytes(ei.instance) 29 }