MCPcopy
hub / github.com/purpleidea/mgmt / event

Method event

lang/funcs/dage/dage.go:693–705  ·  view source on GitHub ↗

event is ultimately called from a function to trigger an event in the engine. We'd like for this to never block, because that makes it much easier to prevent deadlocks in some tricky functions. On the other side, we don't want to necessarily merge events if we want to ensure each sent event gets see

(ctx context.Context, state *state)

Source from the content-addressed store, hash-verified

691// again. Instead, we use a buffered channel of size one, and a queue of data
692// which stores the event information.
693func (obj *Engine) event(ctx context.Context, state *state) error {
694 //f := state.Func // for reference, how to get the Vertex/Func pointer!
695
696 select {
697 case obj.ag.In <- state: // buffered to avoid blocking issues
698 // tell function engine who had an event... deal with it before
699 // we get to handle subsequent ones...
700 case <-ctx.Done():
701 return ctx.Err()
702 }
703
704 return nil
705}
706
707// effect runs at the end of the transaction, but before it returns.
708// XXX: we don't need delta ops if we can just plug into our implementations of

Callers 1

addVertexMethod · 0.95

Calls 2

DoneMethod · 0.65
ErrMethod · 0.65

Tested by

no test coverage detected