Documentation ¶
Index ¶
- func Check(lines []interface{}) ([]string, error)
- func CompleteCondition(c Condition) bool
- func ConditionCheckLines(ctx context.Context, cc chan ConditionCheck, in chan Line, ...)
- func FilterLines(ctx context.Context, a chan FilterAction, in chan Line, w chan Line)
- func FormatLine(line Line) string
- func LoadFile(filename string) ([]interface{}, error)
- func ParseByLine(in io.Reader, out chan interface{}) error
- func ParseFile(filename string, out chan interface{}) error
- func ParseLine(line string) interface{}
- func Play(ctx context.Context, closed chan struct{}, lines []interface{}, ...)
- func Run(ctx context.Context, hup chan os.Signal, ...) error
- func Tee(ctx context.Context, in, in0, in1 chan Line)
- func Write(ctx context.Context, in chan Line, w io.Writer)
- func WsMessageToLine(ctx context.Context, in chan reconws.WsMessage, out chan Line)
- type Comment
- type Condition
- type ConditionCheck
- type Error
- type Filter
- func (f *Filter) Accept(line string) bool
- func (f *Filter) AddAcceptPattern(p *regexp.Regexp)
- func (f *Filter) AddDenyPattern(p *regexp.Regexp)
- func (f *Filter) AllPass() bool
- func (f *Filter) DeleteAcceptPattern(p *regexp.Regexp)
- func (f *Filter) DeleteDenyPattern(p *regexp.Regexp)
- func (f *Filter) Deny(line string) bool
- func (f *Filter) Pass(line string) bool
- func (f *Filter) Reset()
- type FilterAction
- type FilterVerb
- type Line
- type Send
- type Wait
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompleteCondition ¶
CompleteCondition returns true if all parts of the CompleteCondition are holding non-nil equivalent values.
func ConditionCheckLines ¶
func ConditionCheckLines(ctx context.Context, cc chan ConditionCheck, in chan Line, interval time.Duration)
ConditionCheckLines monitors incoming Lines and uses them to assess whether a current condition has been met, which is expressed as Count lines maching the AcceptPattern occuring before the timeout. The Satisfied channel is closed regardless of completion or timeout - there is no indication from ConditionCheckLines whether the condition was satisfied. This is left to any analysis task that the user is presumably coding up separately to analyse the results. In any case, for checking equipment, the condition is normally used to ensure a sufficiency of data with some tolerance, so not exactly meeting the condition is not as much as an issue as it might otherwise be - hence we can leave this to the external analysis to decide.
func FilterLines ¶
func FilterLines(ctx context.Context, a chan FilterAction, in chan Line, w chan Line)
FilterLines intercepts and drops incoming lines, if they don't pass the DenyPattern and AcceptPattern checks
func FormatLine ¶
FormatLine returns a string representing a Line, ready for writing to file
func LoadFile ¶
LoadFile reads a .play file and returns a slice of interfaces each one representing a line in the file
func ParseByLine ¶
ParseByLine reads from the supplied io.Reader, line by line, parsing each line into a struct representing known actions or errors, all of which are returned over out channel
func ParseFile ¶
ParseFile parses a file into an interface per line, which is sent over the out channel.
func ParseLine ¶
func ParseLine(line string) interface{}
ParseLine parses a line and returns a struct representing it, e.g. Wait, Error, Comment, Send.
func Play ¶
func Play(ctx context.Context, closed chan struct{}, lines []interface{}, a chan FilterAction, s chan string, c chan ConditionCheck, w chan Line)
Play takes a slice of Line and plays each Line as required, e.g. Wait, Send (with Delay or Condition), Comment (e.g. echo to file)
func Run ¶
func Run(ctx context.Context, hup chan os.Signal, session, token, logfilename, playfilename string, interval time.Duration, check, force bool) error
Run connects to the session and handles writing to/from files If a playfilename is present, the connection is closed once the file has finished playing A long delay can be left at the end of the playfile to keep the connection open and logging Connections without a playfilename are kept open indefinitely. interval sets how often the condition check timeout is checked - this has a small effect on CPU usage, and can be set at say 10ms for testing, or 1s or more for usage with long collection periods
func Tee ¶
Tee copies incoming Lines on in into copies on in0 and in1 so that they can be consumed for different purposes
Types ¶
type Comment ¶
Comment represents a comment in the playfile which can either be ignored, or echoed to the local logging file.
type Condition ¶
Condition represents a condition for waiting for a number of responses meeting a pattern, or a maximum waiting time, whichever occurs first
type ConditionCheck ¶
type ConditionCheck struct { Condition Condition Satisfied chan struct{} }
ConditionCheck represents a condition that should be checked by ConditionCheckLines.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents an error in the parsing of the playfile
type Filter ¶
type Filter struct { AcceptPatterns *map[string]regexp.Regexp DenyPatterns *map[string]regexp.Regexp }
Filter represents the setting of the logging Filter with a map of patterns to deny (DenyPatterns), and a map of patterns to accept (AcceptPatterns) The mapping is according to the original string used to construct the filter.
func NewFilter ¶
func NewFilter() *Filter
NewFilter returns a pointer to a new, initialised filter ready for use
func (*Filter) AddAcceptPattern ¶
AddAcceptPattern adds a pattern to the AcceptPatterns that will be used to check if a message is accepted (passed)
func (*Filter) AddDenyPattern ¶
AddDenyPattern adds a pattern to the DenyPatterns that will be used to check if a message is denied (blocked)
func (*Filter) AllPass ¶
AllPass returns true if both AcceptPatterns and DenyPatterns are empty, i.e. all messages should pass. we do this for convenience and efficiency, rather than having an explict 'all pass' filter added to the AcceptList because we'd have to remove it the first time we add a filter and the second time we add a filter we'd have to check whether the first filter was the allpass one, and we might not know whether that was from initialisation or explicitly added by a user ....
func (*Filter) DeleteAcceptPattern ¶
DeleteAcceptPattern will remove a given pattern from the list of patterns used to check for acceptance of a line
func (*Filter) DeleteDenyPattern ¶
DeleteDenyPattern will remove a given pattern from the list of patterns used to check for denial of a line
type FilterAction ¶
type FilterAction struct { Verb FilterVerb Pattern *regexp.Regexp }
FilterAction represents an action taken on the setting of the logging filter
type FilterVerb ¶
type FilterVerb int
FilterVerb represents names of actions that can be taken on settings of the logging filter
const ( //Unknown do nothing Unknown FilterVerb = iota // Accept add an AcceptPattern Accept // Deny add a DenyPattern Deny // Remove all AcceptPattern and DenyPatterns (make filter all-pass again) Reset )
These const represent what type of filter action is needed
func (*FilterVerb) String ¶
func (v *FilterVerb) String() string