micro-wrapper-broker/event.go
Vasiliy Tolstov 4de4aafd84 initial import
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-01 01:26:35 +03:00

51 lines
895 B
Go

package broker
import (
"strings"
"github.com/unistack-org/micro/v3/broker"
"github.com/unistack-org/micro/v3/codec"
"github.com/unistack-org/micro/v3/metadata"
)
type event struct {
event broker.Event
}
func (evt *event) Topic() string {
return evt.event.Topic()
}
func (evt *event) Payload() interface{} {
return nil
}
func (evt *event) ContentType() string {
return "raw"
}
func (evt *event) AddHeader(md metadata.Metadata) {
if evt.event.Message().Header == nil {
evt.event.Message().Header = make(metadata.Metadata)
}
for k, v := range md {
evt.event.Message().Header[strings.Title(k)] = v
}
}
func (evt *event) Header() map[string]string {
return evt.event.Message().Header
}
func (evt *event) Body() []byte {
return evt.event.Message().Body
}
func (evt *event) Codec() codec.Reader {
return nil
}
func (evt *event) Event() broker.Event {
return evt.event
}