Add pluggable codec support

This commit is contained in:
Asim
2015-11-25 19:50:05 +00:00
parent 04e07f4b39
commit 12a1e1eeda
8 changed files with 248 additions and 64 deletions

View File

@@ -7,9 +7,11 @@ import (
)
type options struct {
broker broker.Broker
registry registry.Registry
transport transport.Transport
contentType string
codecs map[string]CodecFunc
broker broker.Broker
registry registry.Registry
transport transport.Transport
}
func Broker(b broker.Broker) Option {
@@ -18,6 +20,18 @@ func Broker(b broker.Broker) Option {
}
}
func Codec(contentType string, cf CodecFunc) Option {
return func(o *options) {
o.codecs[contentType] = cf
}
}
func ContentType(ct string) Option {
return func(o *options) {
o.contentType = ct
}
}
func Registry(r registry.Registry) Option {
return func(o *options) {
o.registry = r