package broker

import "context"

var (
	Default Broker
)

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

func SetGlobal(bus Broker) {
	Default = bus
}

func GetGlobal() Broker {
	return Default
}

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

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

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

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

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