Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadService ¶
func LoadService(db *badger.DB, service *pb.Service, status *pb.ServiceStatus) error
LoadService from badger KV store. Service is uniquely identified by pb.ServiceStatus.Identifier.
func MustConnectOnBuffer ¶
func MustConnectOnBuffer(sender Sender) *grpc.ClientConn
func SaveService ¶
SaveService to badger KV store using protobuf. If service with given pb.Service.Identifier exists it will be overwritten.
Types ¶
type Availability ¶
type Availability struct {
// contains filtered or unexported fields
}
Availability triggers action with respect to provided timeout and Ping calls.
func NewAvailability ¶
func NewAvailability(timeout time.Duration, callback func(bool)) *Availability
NewAvailability creates new Availability struct with provided timeout and callback. Use av.Run() function to start detecting availability changes. Call av.Ping() to renew timeout. Callback will be called after first Ping() call. We assume initial inavailability. New Timer is created, so callback will be called unless Availability is pinged in prvided timeout.
func (*Availability) Ping ¶
func (a *Availability) Ping()
Ping to renew timeout. Must call Run() before in seperate goroutine.
func (*Availability) Run ¶
func (a *Availability) Run()
Run will detect availability changes. Should be run in seperate goroutine. Callbacks are called in seperate goroutine. Callback will be called with false when timeout has expired since last Ping
type Sender ¶
type Sender interface { SendAvailability(service string, availability bool) error SendStatus(service string, status string) error }
Sender is used to send availability and status (e.g. to Slack) when change is detected.
type Server ¶
type Server struct { pb.UnimplementedProcjonServer Sender Sender DB *badger.DB }
func (*Server) RegisterService ¶
RegisterService in procjon and save it in badger KV store. This registration will persist across procjon restarts.
func (*Server) SendServiceStatus ¶
func (s *Server) SendServiceStatus(stream pb.Procjon_SendServiceStatusServer) error
SendServiceStatus. Service must be registered first with RegisterService.
type StatusCode ¶
type StatusCode struct {
// contains filtered or unexported fields
}
StatusCode just holds the value provided in last HasChanged() call.
func (*StatusCode) HasChanged ¶
func (stc *StatusCode) HasChanged(new uint32) (changed bool)
HasChanged returns true if new is different than value from previous call. Otherwise, it returns false.