package broker

import "context"

var (
	std Broker
)

func init() {
	std = NewInPrcBus(context.Background())
}

func SetGlobal(bus Broker) {
	std = bus
}

func GetGlobal() Broker {
	return std
}

func WithContext(ctx context.Context) {
	std.WithContext(ctx)
}

func Publish(e *Event) {
	std.Publish(e)
}

func Dispatch(e *Event) (err error) {
	return std.Dispatch(e)
}

func DispatchCtx(ctx context.Context, e *Event) (err error) {
	return std.DispatchCtx(ctx, e)
}

func Subscribe(sub Subscriber) (err error) {
	return std.Subscribe(sub)
}

func UnSubscribe(sub Subscriber) (err error) {
	return std.UnSubscribe(sub)
}
