mirror of
https://github.com/oarkflow/mq.git
synced 2025-10-05 07:57:00 +08:00
feat: separate broker
This commit is contained in:
28
util.go
Normal file
28
util.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package mq
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/oarkflow/mq/codec"
|
||||
)
|
||||
|
||||
func (b *Broker) TLSConfig() TLSConfig {
|
||||
return b.opts.tlsConfig
|
||||
}
|
||||
|
||||
func (b *Broker) SyncMode() bool {
|
||||
return b.opts.syncMode
|
||||
}
|
||||
|
||||
func (b *Broker) HandleCallback(ctx context.Context, msg *codec.Message) {
|
||||
if b.opts.callback != nil {
|
||||
var result Result
|
||||
err := json.Unmarshal(msg.Payload, &result)
|
||||
if err == nil {
|
||||
for _, callback := range b.opts.callback {
|
||||
callback(ctx, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user