2021-09-12 23:24:22 +03:00
|
|
|
package drpc
|
|
|
|
|
|
|
|
import (
|
2021-10-27 18:13:33 +03:00
|
|
|
"go.unistack.org/micro/v3/client"
|
2021-12-16 15:27:02 +03:00
|
|
|
"go.unistack.org/micro/v3/metadata"
|
2021-09-12 23:24:22 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type drpcEvent struct {
|
|
|
|
payload interface{}
|
|
|
|
topic string
|
|
|
|
contentType string
|
2021-12-16 15:27:02 +03:00
|
|
|
opts client.MessageOptions
|
2021-09-12 23:24:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func newDRPCEvent(topic string, payload interface{}, contentType string, opts ...client.MessageOption) client.Message {
|
2021-12-16 15:27:02 +03:00
|
|
|
options := client.NewMessageOptions(opts...)
|
2021-09-12 23:24:22 +03:00
|
|
|
|
|
|
|
if len(options.ContentType) > 0 {
|
|
|
|
contentType = options.ContentType
|
|
|
|
}
|
|
|
|
|
|
|
|
return &drpcEvent{
|
|
|
|
payload: payload,
|
|
|
|
topic: topic,
|
2021-12-16 15:27:02 +03:00
|
|
|
opts: options,
|
2021-09-12 23:24:22 +03:00
|
|
|
contentType: contentType,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *drpcEvent) ContentType() string {
|
|
|
|
return d.contentType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *drpcEvent) Topic() string {
|
|
|
|
return d.topic
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *drpcEvent) Payload() interface{} {
|
|
|
|
return d.payload
|
|
|
|
}
|
2021-12-16 15:27:02 +03:00
|
|
|
|
|
|
|
func (d *drpcEvent) Metadata() metadata.Metadata {
|
|
|
|
return d.opts.Metadata
|
|
|
|
}
|