//Register add a handler to consume specific topic
Register add a handler to consume specific topic
// Register add a handler to consume specific topic
func (d *redisDispatcher) Register(ctx context.Context, topic Topic, handler HandleFunc) error {
	if d.isStopped() {
		return ErrDispatcherNotWorking
	}
	d.Lock()
	defer d.Unlock()
	if _, ok := d.handlers[topic]; !ok {
		d.handlers[topic] = []HandleFunc{}
	}
	for tpc, handlers := range d.handlers {
		if tpc == topic {
			d.handlers[tpc] = append(handlers, handler)
		}
	}
	return nil
}
func ( d * redisDispatcher ) Register ( ctx context . Context , topic Topic , handler HandleFunc ) error { if d . isStopped ( ) { return ErrDispatcherNotWorking } d . Lock ( ) defer d . Unlock ( ) if _ , ok := d . handlers [ topic ] ; ! ok { d . handlers [ topic ] = [ ] HandleFunc { } } for tpc , handlers := range d . handlers { if tpc == topic { d . handlers [ tpc ] = append ( handlers , handler ) } } return nil }
Register add a handler to consume specific topic
Register add a handler to consume specific topic