Add some docs

This commit is contained in:
Sean Braithwaite 2019-08-13 19:29:28 +02:00
parent 78d4c3b88a
commit f81c319ece

View File

@ -14,6 +14,12 @@ import (
type handleFunc = func(event Event) (Events, error) type handleFunc = func(event Event) (Events, error)
// Routines are a structure which model a finite state machine as serialized
// stream of events processed by a handle function. This Routine structure
// handles the concurrency and messaging guarantees. Events are sent via
// `trySend` are handled by the `handle` function to produce an iterator
// `next()`. Calling `close()` on a routine will conclude processing of all
// sent events and produce `last()` event representing the terminal state.
type Routine struct { type Routine struct {
name string name string
input chan Event input chan Event
@ -56,7 +62,6 @@ func (rt *Routine) setMetrics(metrics *Metrics) {
} }
func (rt *Routine) start() { func (rt *Routine) start() {
// what if we call baseService.start
rt.logger.Info(fmt.Sprintf("%s: run\n", rt.name)) rt.logger.Info(fmt.Sprintf("%s: run\n", rt.name))
starting := atomic.CompareAndSwapUint32(rt.running, uint32(0), uint32(1)) starting := atomic.CompareAndSwapUint32(rt.running, uint32(0), uint32(1))
if !starting { if !starting {