Commit Graph

11 Commits

Author SHA1 Message Date
Paul Stemmet 6ab808c6f5
fifo/mock: MockEvents
Mock producer which implements fifo.EventChannel. Useful elsewhere in
the code, and also to kdnotify/fifo users.
2022-12-09 18:05:57 +00:00
Paul Stemmet 65660e3286
fifo: EventChannel, FifoChannel
This commit adds the fifo.EventChannel interface for consuming (VRRP)
events from keepalived.

This is what package users should accept when expecting a handle to the
event stream.

fifo.FifoChannel is an implementation of this against an IPC FIFO channel
opened via MkFifo(), and can be considered the primary "producer" of
fifo.EventChannel events, but importantly we can create other
producers, notably for testing.
2022-12-09 18:05:56 +00:00
Paul Stemmet 69ceb4eab3
schema/notify: Message, VrrpMessage
The in-memory representation of a keepalived notify event.

Message is not strictly accurate for non VRRP events, but as we don't
care about IPVS events now this is fine for our purposes. We do
explicitly provide a VrrpMessage type however which is guaranteed to be
a VRRP event.
2022-12-09 18:05:56 +00:00
Paul Stemmet a44d541cb7
schema/notify: prio.Priority
A uint number between 0 and 255, representing the new priority of the
associated INSTANCE. In newer versions of the VRRP protocol (v2+) a
instance's priority must be 255 to be considered MASTER, but older
versions only require the highest current priority to be MASTER.

This field is also _optional_ keepalived will only output it for VRRP
events, and then only if a setting is enabled in the conf file,
'vrrp_notify_priority_changes'.

  TYPE INSTANCE STATE PRIORITY
                      ^^^^^^^^
2022-12-09 18:05:56 +00:00
Paul Stemmet 30de46d643
schema/notify: state.State
Representation of the STATE component in a keepalived notify event.

Can be one of: MASTER,BACKUP,STOP (for VRRP events)

  TYPE INSTANCE STATE PRIORITY
                ^^^^^
2022-12-09 18:05:55 +00:00
Paul Stemmet 97be796dfc
schema/notify: ty.Type
These correspond to the TYPE produced by keepalived's notify events.

It may be one of: INSTANCE,GROUP,VS,RS as of this commit.

Our focus is only on supporting VRRP event types at present, but we do
recognize all the current event types.

  TYPE INSTANCE STATE PRIORITY
  ^^^^
2022-12-09 18:05:55 +00:00
Paul Stemmet f0bacb8000
config: LibCxt
This is a "global" context object currently containing a cancellation
context and logger.

This struct can be considered as the lib's generic configuration, and
may be asked for in any public function.
2022-12-09 18:05:55 +00:00
Paul Stemmet 21aa140aa1
go.mod: add shellwords + tidy
Used in handler/template.go for parsing the cmdline passed through by
users in config
2022-12-09 18:05:54 +00:00
Paul Stemmet 59204d6bd1
fifo: add MkPipe/1
for creating the underlying IPC channel that we'll use for communication
with keepalived
2022-12-09 18:05:54 +00:00
Paul Stemmet 7741d7b119
mod: +containerd/fifo +stretchr/testify 2022-11-24 14:20:39 +00:00
Paul Stemmet 5aff11c0a8
repo: Genesis 2022-11-24 12:43:17 +00:00