Documentation ¶
Overview ¶
Package zedhook implements client and server logic for the zedhookd system.
Index ¶
- type Client
- type Event
- type Handler
- type ListEventsOptions
- type Payload
- type Server
- type Status
- type Storage
- func (s *Storage) Close() error
- func (s *Storage) GetEvent(ctx context.Context, id int) (Event, error)
- func (s *Storage) LatestEvents(ctx context.Context) ([]Event, error)
- func (s *Storage) ListEvents(ctx context.Context, o ListEventsOptions) ([]Event, error)
- func (s *Storage) SaveEvent(ctx context.Context, e Event) error
- type Variable
- type Version
- type ZpoolPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is a client for the zedhookd server.
func NewClient ¶
NewClient creates a Client for the zedhookd server specified by addr.
If addr is empty, the default zedhookd addresses will be tried in order:
- http+unix:///run/zedhookd/zedhookd.sock:/push
- http://localhost:9919/push
If a non-empty addr is set, that address will be used and no fallback paths will be attempted.
If c is nil, a default HTTP client which supports "http", "https", "http+unix", and "https+unix" address schemes (see https://github.com/peterbourgon/unixtransport) will be configured.
type Event ¶
type Event struct { // Core metadata about an Event. ID, EventID int Timestamp time.Time Class, Zpool string // Unprocessed variables associated with the Event. Variables []Variable // Optional zpool status output logged with the Event. Status *Status }
An Event is the processed version of a client Payload.
func (Event) MarshalJSON ¶
MarshalJSON returns the JSON object for an Event.
func (*Event) UnmarshalJSON ¶
UnmarshalJSON unpacks the JSON for an Event.
type Handler ¶
type Handler struct { // OnPayload is an optional hook which is fired when a valid zedhook payload // push request is sent to a Server. If not nil, the callback will be fired // with the contents of the Payload. OnPayload func(p Payload) // contains filtered or unexported fields }
A Handler is an http.Handler for zedhookd logic.
type ListEventsOptions ¶
ListEventsOptions provides arguments for the Storage.ListEvents method.
type Payload ¶
type Payload struct { // Environment variable key/value pairs set by ZED and gathered by a Client. Variables []Variable // Optional data gathered by executing the zpool command. Zpool *ZpoolPayload // contains filtered or unexported fields }
A Payload is the top-level zedhook payload container.
func (Payload) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Payload) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
A Server is the zedhookd server entry point.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage is persistent storage backed by sqlite3.
func MemoryStorage ¶
func MemoryStorage() *Storage
MemoryStorage creates ephemeral sqlite-backed in-memory storage.
func NewStorage ¶
NewStorage creates a sqlite-backed persistent storage using the input DSN.
func (*Storage) LatestEvents ¶
LatestEvents lists the latest event of each unique class for each zpool from the database.
func (*Storage) ListEvents ¶
ListEvents lists Events from the database given a set of options.
type ZpoolPayload ¶
type ZpoolPayload struct { // The raw output of 'zpool status tank'. RawStatus []byte `json:"raw_status"` }
A ZpoolPayload contains information from executing a zpool command.