rocketmq-client-go
rocketmq-client-go copied to clipboard
the interface `rocketmq.Producer` can't be implemented outside
type Producer interface {
Start() error
Shutdown() error
SendSync(ctx context.Context, mq ...*primitive.Message) (*primitive.SendResult, error)
SendAsync(ctx context.Context, mq func(ctx context.Context, result *primitive.SendResult, err error),
msg ...*primitive.Message) error
SendOneWay(ctx context.Context, mq ...*primitive.Message) error
Request(ctx context.Context, ttl time.Duration, msg *primitive.Message) (*primitive.Message, error)
RequestAsync(ctx context.Context, ttl time.Duration, callback internal.RequestCallback, msg *primitive.Message) error
}
the struct RequestCallback
in package internal
, so the interface Producer
can't be implemented outside
In what case do we need to implement this interface ourselves?
for example, I want to write a MockProducer to print log only, for test
using an internal type as an exported function's parameter is really a bad idea