From f81c319ecef8b20c7f77b817177f8305b3232bb3 Mon Sep 17 00:00:00 2001 From: Sean Braithwaite Date: Tue, 13 Aug 2019 19:29:28 +0200 Subject: [PATCH] Add some docs --- blockchain/v2/routine.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/blockchain/v2/routine.go b/blockchain/v2/routine.go index ecd12c82..08941470 100644 --- a/blockchain/v2/routine.go +++ b/blockchain/v2/routine.go @@ -14,6 +14,12 @@ import ( 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 { name string input chan Event @@ -56,7 +62,6 @@ func (rt *Routine) setMetrics(metrics *Metrics) { } func (rt *Routine) start() { - // what if we call baseService.start rt.logger.Info(fmt.Sprintf("%s: run\n", rt.name)) starting := atomic.CompareAndSwapUint32(rt.running, uint32(0), uint32(1)) if !starting {