//Dispatch push an event to redis
Dispatch push an event to redis
// Dispatch push an event to redis
func (d *redisDispatcher) Dispatch(ctx context.Context, topic Topic, evt Event) error {
	if d.isStopped() {
		return ErrDispatcherNotWorking
	}
	emitAt := time.Now()
	if delayedEvt, ok := evt.(DelayedEvent); ok {
		emitAt = emitAt.Add(delayedEvt.Delayed())
	}
	emitEvt := &DispatchedEvent{Event: evt, EmitAt: emitAt}
	d.RLock()
	defer d.RUnlock()
	return d.clientWrapper.ZAdd(ctx, topic, emitEvt)
}
func ( d * redisDispatcher ) Dispatch ( ctx context . Context , topic Topic , evt Event ) error { if d . isStopped ( ) { return ErrDispatcherNotWorking } emitAt := time . Now ( ) if delayedEvt , ok := evt . ( DelayedEvent ) ; ok { emitAt = emitAt . Add ( delayedEvt . Delayed ( ) ) } emitEvt := & DispatchedEvent { Event : evt , EmitAt : emitAt } d . RLock ( ) defer d . RUnlock ( ) return d . clientWrapper . ZAdd ( ctx , topic , emitEvt ) }
Dispatch push an event to redis
Dispatch push an event to redis
//examine emit time //dispatch events should lock while handler change, concurrency dispatch is allowed