Package event defines Lucifer events and a function for running Lucifer with an event handler.



    This section is empty.


    This section is empty.


    func AbortWhenDone

    func AbortWhenDone(ctx context.Context, path string) context.CancelFunc

      AbortWhenDone forwards an abort message to an abort socket when provided context is Done().

      This function spawns a goroutine that is cleaned up when the returned CancelFunc is called.

      func Handle

      func Handle(r io.Reader, f Handler) error

        Handle handles events read from an io.Reader. The handler function is called for each event with the event and message strings. Use a closure to keep state or to store errors. This function only returns an error if event parsing fails.

        func RunCommand

        func RunCommand(c *exec.Cmd, f Handler) error

          RunCommand runs an exec.Cmd that uses the event protocol and calls Handle on with the provided handler function to handle events.


          type Event

          type Event string

            Event is a string enum type for valid events to pass to Send and SendWithMsg. Handler functions should be able to handle all of these.

            const (
            	// Starting indicates that the task is beginning to run.
            	Starting Event = "starting"
            	// The following events indicate task status.  The handler may
            	// use these to track task status.
            	Provisioning Event = "provisioning"
            	Running      Event = "running"
            	Gathering    Event = "gathering"
            	Parsing      Event = "parsing"
            	Aborted      Event = "aborted"
            	// Completed indicates that the task has completed.  The
            	// handler may run any post-task logic on receiving this
            	// event.
            	Completed Event = "completed"

              Task status events.

              const (
              	TestPassed Event = "test_passed"
              	TestFailed Event = "test_failed"

                Test status events.

                const (
                	// HostClean indicates that the host is ready to run tests and
                	// that it is clean.  The handler should mark the host as not
                	// dirty if the handler is tracking host dirtiness.  HostClean
                	// should be considered a superset of HostReady.
                	HostClean        Event = "host_clean"
                	HostFailedRepair Event = "host_failed_repair"
                	HostNeedsCleanup Event = "host_needs_cleanup"
                	HostNeedsRepair  Event = "host_needs_repair"
                	HostNeedsReset   Event = "host_needs_reset"
                	// HostReady indicates that the host is ready to run tests.
                	// HostReady should not be sent together with HostClean.
                	HostReady Event = "host_ready"
                	// HostReadyToRun indicates that the host is ready to run
                	// tests, after provisioning and before running tests as part
                	// of a Lucifer task.  This is a transitory state, not a final
                	// state like HostReady.
                	HostReadyToRun Event = "host_ready_to_run"
                	// HostRunning indicates that the host is running a test.  The
                	// handler may mark the host as dirty if the handler is
                	// tracking host dirtiness.
                	HostRunning Event = "host_running"
                	// NeedsDeploy indicates that the host fails the deploy task and needs
                	// to be deployed again.
                	HostNeedsDeploy Event = "host_needs_deploy"
                	// HostNeedsManualRepair indicates that the host required manual attention to be fixed
                	HostNeedsManualRepair Event = "host_needs_manual_repair"
                	// HostNeedsReplacement indicates that the host is not fixable due issues with hardware and has to be replaced
                	HostNeedsReplacement Event = "host_needs_replacement"

                  Host status events.

                  type Forwarder

                  type Forwarder struct {
                  	// contains filtered or unexported fields

                    Forwarder encapsulates cleanup for ForwardAbortSignal.

                    func ForwardAbortSignal

                    func ForwardAbortSignal(path string) *Forwarder

                      ForwardAbortSignal catches termination signals and forwards them as abort messages to an abort socket. This function spawns a goroutine and modifies the process signal handlers. Both of these are cleaned up when the returned Forwarder is closed.

                      func (*Forwarder) Close

                      func (f *Forwarder) Close()

                        Close cleans up signal forwarding stuff. Subsequent calls do nothing.

                        type Handler

                        type Handler func(e Event, m string)

                          Handler is the type for valid functions to pass to Handle.

                          GOOS=linux, GOARCH=amd64