Documentation ¶
Index ¶
- type Channels
- type Substation
- func (sub *Substation) Block(ctx context.Context) error
- func (sub *Substation) CreateChannels(size int)
- func (sub *Substation) DoneSignal()
- func (sub *Substation) KillSignal()
- func (sub *Substation) SendErr(err error)
- func (sub *Substation) SendTransform(b []byte)
- func (sub *Substation) Sink(ctx context.Context, wg *sync.WaitGroup)
- func (sub *Substation) SinkSignal()
- func (sub *Substation) Transform(ctx context.Context, wg *sync.WaitGroup)
- func (sub *Substation) TransformSignal()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channels ¶
type Channels struct { Done chan struct{} Kill chan struct{} Errs chan error Transform chan []byte Sink chan []byte }
Channels contains channels used by the app for managing state and transferring data.
Done: used for signaling that all data processing (ingest, transform, load) is complete; this is always invoked by the Sink goroutine Kill: used for signaling that all non-anonymous goroutines should end processing Errs: used for signaling that an error occurred from an internal component Transform: used for transferring data from the handler to the Transform goroutines Sink: used for passing data from the Transform goroutines to the Sink goroutine
type Substation ¶
type Substation struct { Channels Channels Config config }
Substation is the application core, all data processing and flow happens through Substation.
func (*Substation) Block ¶
func (sub *Substation) Block(ctx context.Context) error
Block blocks the handler from returning until one of these conditions is met: - the handler request times out (ctx.Done) - a data processing error occurs - all data processing is complete
This is usually the final call made by main() in a cmd invoking the app.
func (*Substation) CreateChannels ¶
func (sub *Substation) CreateChannels(size int)
CreateChannels initializes channels used by the app. Non-blocking channels can leak if the caller closes before processing completes; this is most likely to happen if the caller uses context to timeout. To avoid goroutine leaks, set larger buffer sizes.
func (*Substation) DoneSignal ¶
func (sub *Substation) DoneSignal()
DoneSignal closes the Done channel. This signals that all data was sent to a sink. This should only be called by the Sink goroutine.
func (*Substation) KillSignal ¶
func (sub *Substation) KillSignal()
KillSignal closes the Kill channel. This signals all non-anonymous goroutines to stop running. This should always be deferred by the cmd invoking the app.
func (*Substation) SendErr ¶
func (sub *Substation) SendErr(err error)
SendErr puts an error into the Errs channel.
func (*Substation) SendTransform ¶
func (sub *Substation) SendTransform(b []byte)
SendTransform puts byte data into the Transform channel.
func (*Substation) Sink ¶
func (sub *Substation) Sink(ctx context.Context, wg *sync.WaitGroup)
Sink is the data sink method for the app. Data is input on the Sink channel and sent to the configured sink. Sink finished when the Sink channel is closed.
func (*Substation) SinkSignal ¶
func (sub *Substation) SinkSignal()
SinkSignal closes the Sink channel. This signals that there is no more data to send. This should only be called by the cmd invoking the app.
func (*Substation) Transform ¶
func (sub *Substation) Transform(ctx context.Context, wg *sync.WaitGroup)
Transform is the data transformation method for the app. Data is input on the Transform channel, transformed by a Transform interface (see: internal/transform), and output on the Sink channel. All Transform goroutines finish when the Transform channel is closed.
func (*Substation) TransformSignal ¶
func (sub *Substation) TransformSignal()
TransformSignal closes the Transform channel. This signals that there is no more incoming data to process. This should only be called by the cmd invoking the app.