es

package
v0.0.0-...-3736fb9 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package es contains an emergency stop implementation. This data is read from es.json file every 10 seconds. If the data changes, subscribers will receive an update.

Using this is simple:

ch, cancel := es.Data.Subscribe("SatelliteDiskErase")
defer cancel()

if <-ch != es.Go {
	// Do something
}

select {
case <-ch:
	log.Println("ES changed to Stop state ")
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cancel

type Cancel func()

Cancel is used to cancel your subscription.

type Info

type Info struct {
	// Name is the WorkReq type.
	Name string
	// Status is the emergency stop status.
	Status Status
}

Info is the emergency stop information for a particular entry in our es.json file.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader reads the es.json file at intervals and makes the data and changes to the data available.

var Data *Reader

Data is how to access the emergency stop information.

func (*Reader) Status

func (r *Reader) Status(name string) Status

Status returns the ES status for the named workflow.

func (*Reader) Subscribe

func (r *Reader) Subscribe(name string) (chan Status, Cancel)

Subscribe returns a channel that sends a Status whenever a ES entry changes status. This will send the initial Status immediately. If the name is not found, this will send Stop and close the channel. If there is a transition to Stop, the channel will be closed once this is sent. Once you either receive a Stop or are no longer interested in listening, simply call Cancel().

type Status

type Status string

Status indicates the emergency stop status.

const (
	// Unknown means the status was not set.
	Unknown Status = ""
	// Go indicates the matching workflow can execute.
	Go Status = "go"
	// Stop indicates that the matching workflow should not execute and
	// existing ones should be stopped.
	Stop Status = "stop"
)

Jump to

Keyboard shortcuts

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