func (o *Outboxer) StartDispatcher(ctx context.Context) {
	ticker := time.NewTicker(o.checkInterval)

	for {
		select {
		case <-ticker.C:
			evts, err := o.ds.GetEvents(ctx, o.messageBatchSize)
			if err != nil {
				o.errChan <- err
				break
			}

			for _, e := range evts {
				if err := o.es.Send(ctx, e); err != nil {
					o.errChan <- err
				} else {
					if err := o.ds.SetAsDispatched(ctx, e.ID); err != nil {
						o.errChan <- err
					} else {
						o.okChan <- struct{}{}
					}
				}
			}
		case <-ctx.Done():
			return
		}
	}
}
// StartDispatcher starts the dispatcher, which is responsible for getting the messages
// from the data store and sending to the event stream.
StartDispatcher starts the dispatcher, which is responsible for getting the messages
from the data store and sending to the event stream.
// StartDispatcher starts the dispatcher which is responsible for getting the messages // from the data store and sending to the event stream .
func (o *Outboxer) StartDispatcher(ctx context.Context) {
	ticker := time.NewTicker(o.checkInterval)
	for {
		select {
		case <-ticker.C:
			evts, err := o.ds.GetEvents(ctx, o.messageBatchSize)
			if err != nil {
				o.errChan <- err
				break
			}
			for _, e := range evts {
				if err := o.es.Send(ctx, e); err != nil {
					o.errChan <- err
				} else {
					if err := o.ds.SetAsDispatched(ctx, e.ID); err != nil {
						o.errChan <- err
					} else {
						o.okChan <- struct{}{}
					}
				}
			}
		case <-ctx.Done():
			return
		}
	}
}
func ( o * Outboxer ) StartDispatcher ( ctx context . Context ) { ticker := time . NewTicker ( o . checkInterval ) for { select { case <- ticker . C : evts , err := o . ds . GetEvents ( ctx , o . messageBatchSize ) if err != nil { o . errChan <- err break } for _ , e := range evts { if err := o . es . Send ( ctx , e ) ; err != nil { o . errChan <- err } else { if err := o . ds . SetAsDispatched ( ctx , e . ID ) ; err != nil { o . errChan <- err } else { o . okChan <- struct { } { } } } } case <- ctx . Done ( ) : return } } }
StartDispatcher starts the dispatcher, which is responsible for getting the messages
from the data store and sending to the event stream.
StartDispatcher starts the dispatcher which is responsible for getting the messages from the data store and sending to the event stream .