//Dispatch dispatch a event to a topic, support multi dispatchers to receive events
//should keep idempotent for event handling
Dispatch dispatch a event to a topic, support multi dispatchers to receive events
should keep idempotent for event handling
// Dispatch dispatch a event to a topic support multi dispatchers to receive events // should keep idempotent for event handling
func Dispatch(ctx context.Context, topic Topic, evt Event, dispatcher Dispatcher, dispatchers ...Dispatcher) error {
	if "" == topic.String() {
		return ErrNoTopicSpecified
	}
	if nil == evt {
		return ErrNoEventSpecified
	}
	if nil == dispatcher {
		return ErrNoDispatcherSpecified
	}
	allDispatchers := append(dispatchers, dispatcher)
	for _, disp := range allDispatchers {
		if err := disp.Dispatch(ctx, topic, evt); nil != err {
			return err
		}
	}
	return nil
}
func Dispatch ( ctx context . Context , topic Topic , evt Event , dispatcher Dispatcher , dispatchers ... Dispatcher ) error { if " " == topic . String ( ) { return ErrNoTopicSpecified } if nil == evt { return ErrNoEventSpecified } if nil == dispatcher { return ErrNoDispatcherSpecified } allDispatchers := append ( dispatchers , dispatcher ) for _ , disp := range allDispatchers { if err := disp . Dispatch ( ctx , topic , evt ) ; nil != err { return err } } return nil }
Dispatch dispatch a event to a topic, support multi dispatchers to receive events
should keep idempotent for event handling
Dispatch dispatch a event to a topic support multi dispatchers to receive events should keep idempotent for event handling