ugly fix for nil context
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
28190f9489
commit
553fc8b998
@ -177,9 +177,11 @@ func (k *kBroker) Publish(topic string, msg *broker.Message, opts ...broker.Publ
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
kmsg := kafka.Message{Value: val}
|
kmsg := kafka.Message{Value: val}
|
||||||
|
if options.Context != nil {
|
||||||
if key, ok := options.Context.Value(publishKey{}).([]byte); ok && len(key) > 0 {
|
if key, ok := options.Context.Value(publishKey{}).([]byte); ok && len(key) > 0 {
|
||||||
kmsg.Key = key
|
kmsg.Key = key
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
k.Lock()
|
k.Lock()
|
||||||
writer, ok := k.writers[topic]
|
writer, ok := k.writers[topic]
|
||||||
|
Loading…
Reference in New Issue
Block a user