github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/automation/hook/hook.go (about)

     1  package hook
     2  
     3  import (
     4  	"encoding/json"
     5  	"fmt"
     6  
     7  	"github.com/qri-io/qri/event"
     8  )
     9  
    10  var (
    11  	// ErrUnexpectedType indicates the hook type is unexpected
    12  	ErrUnexpectedType = fmt.Errorf("unexpected hook type")
    13  )
    14  
    15  // A Hook determines under what circumstances its `event.Type` should be
    16  // emitted, and what the event payload should be.
    17  type Hook interface {
    18  	json.Marshaler
    19  	json.Unmarshaler
    20  	// Enabled returns whether the Hook is enabled
    21  	Enabled() bool
    22  	// SetEnabled sets the enabled status
    23  	SetEnabled(enabled bool) error
    24  	// Type returns the type of Hook
    25  	Type() string
    26  	// Advance adjusts the Hook once it has been triggered
    27  	Advance() error
    28  	// Event returns the event.Type associated with this Hook as well as
    29  	// the payload that should be emitted along with the event
    30  	Event() (event.Type, interface{})
    31  }