rocketmq-client-go icon indicating copy to clipboard operation
rocketmq-client-go copied to clipboard

the interface `rocketmq.Producer` can't be implemented outside

Open twz915 opened this issue 1 year ago • 3 comments

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

twz915 avatar Apr 26 '23 13:04 twz915

In what case do we need to implement this interface ourselves?

cserwen avatar Apr 27 '23 02:04 cserwen

for example, I want to write a MockProducer to print log only, for test

twz915 avatar Apr 27 '23 05:04 twz915

using an internal type as an exported function's parameter is really a bad idea

oxcafebabe avatar Sep 06 '23 10:09 oxcafebabe