hook

package
v1.8.0-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent interface {
	// Trigger hooks
	Trigger(evt *Event) error
	// Serves events now
	Serve() error
	// Attach a job life cycle controller
	Attach(ctl lcm.Controller)
}

Agent is designed to handle the hook events with reasonable numbers of concurrent threads

func NewAgent

func NewAgent(ctx *env.Context, ns string, redisPool *redis.Pool) Agent

NewAgent is constructor of basic agent

type Client

type Client interface {
	// SendEvent send the event to the subscribed parties
	SendEvent(evt *Event) error
}

Client for handling the hook events

func NewClient

func NewClient(ctx context.Context) Client

NewClient return the ptr of the new hook client

type Event

type Event struct {
	URL       string            `json:"url"`
	Message   string            `json:"message"`   // meaningful text for event
	Data      *job.StatusChange `json:"data"`      // generic data
	Timestamp int64             `json:"timestamp"` // Use as time threshold of discarding the event (unit: second)
}

Event contains the hook URL and the data

func (*Event) Deserialize

func (e *Event) Deserialize(bytes []byte) error

Deserialize the bytes to event

func (*Event) Serialize

func (e *Event) Serialize() ([]byte, error)

Serialize event to bytes

func (*Event) Validate

func (e *Event) Validate() error

Validate event

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL