unio

package
v0.0.0-...-8b292c0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

********************************************************************************** The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **********************************************************************************

********************************************************************************** The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **********************************************************************************

********************************************************************************** The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **********************************************************************************

********************************************************************************** The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **********************************************************************************

********************************************************************************** The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **********************************************************************************

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventBus

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

EventBus is the implementation of the Lightweight Event Bus that holds and manages the current registered events. EventBus is thread safe

func NewEventBus

func NewEventBus(eventBusConfig EventBusConfiguration) *EventBus

NewEventBus creates a new EventBus and returns the reference to the object

func (*EventBus) AddRule

func (bus *EventBus) AddRule(ruleJSON string) (string, error)

AddRule adds a rule to the rules engine and return the rule id, otherwise an empty string is returned

func (*EventBus) AddRuleWithTarget

func (bus *EventBus) AddRuleWithTarget(ruleJSON, ruleString, targetURL string) (string, error)

AddRuleWithTarget adds a rule to the rules engine and adds a target for the rule. It returns the rule id, otherwise an error is returned

func (*EventBus) Start

func (bus *EventBus) Start()

Start starts all of the processes/services used by the EventBus

func (*EventBus) Stop

func (bus *EventBus) Stop()

Stop initiates a shutdown of the Event Bus

func (*EventBus) UpdateRule

func (bus *EventBus) UpdateRule(ruleJSON, ruleID string) error

UpdateRule updates the definition of an existing rule using the passed in rule id and ruleJSON. an error is returned if one occurred

type EventBusAPI

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

EventBusAPI is an API container that holds all of the logic for managing the API interface for Event Bus

func NewEventBusAPI

func NewEventBusAPI(bus *EventBus) *EventBusAPI

NewEventBusAPI creates a new instance of the EventBusAPI and returns a reference to the new object. Otherwise an error is returned if one occurred.

func (*EventBusAPI) GetState

func (api *EventBusAPI) GetState() goapi.State

GetState interrogates the service to understand its current state for status reporting purpopses. This is a RESTService interface implementation

func (*EventBusAPI) Start

func (api *EventBusAPI) Start() error

Start starts the running version of the API and is ready to receive requests

func (*EventBusAPI) Stop

func (api *EventBusAPI) Stop()

Stop initiaties the graceful shutdown of the API's underlying rest service

type EventBusConfiguration

type EventBusConfiguration struct {
	DataAccessConfig dataaccess.DataSourceConfiguration `json:"dataaccessconfig" yaml:"dataaccessconfig"`
	APIConfiguration config.ListenerConfig              `json:"apiconfig" yaml:"apiconfig"`
}

EventBusConfiguration holds all of the configuration information for the EventBus

type PatternRule

type PatternRule struct {
	Pattern     map[string]interface{} `json:"pattern" yaml:"pattern"`
	RuleTargets []RuleTarget           `json:"ruletargets" yaml:"ruletargets"`
	Created     time.Time              `json:"created" yaml:"created"`
	Modified    time.Time              `json:"modified" yaml:"modified"`
	RuleID      string                 `json:"id" yaml:"id"`
	Name        string                 `json:"name" yaml:"name"`
	Description string                 `json:"description" yaml:"description"`
	RuleType    RuleType               `json:"ruletype" yaml:"ruletype"`
}

PatternRule represents rule criteria to be evaluated in order to determine if an event satisifes the requirments fo the rule. The rule itself will be a representation of any object and will use the key value pairs extracted from a JSON Map to determine the rule parameters

func NewRule

func NewRule(rulePattern interface{}) *PatternRule

NewRule generates a new Rule based on the passed in parameters object

func (*PatternRule) AddTarget

func (rule *PatternRule) AddTarget(target RuleTarget) error

AddTarget provides a mechanism for add an additional target to the rule

func (*PatternRule) GetID

func (rule *PatternRule) GetID() string

GetID returns the ID for the rule

func (PatternRule) MarshalJSON

func (rule PatternRule) MarshalJSON() ([]byte, error)

MarshalJSON is a method implemented allowing JSON serialization of the PatternRulelogLevel values from an enumerated type to a string

func (PatternRule) Matches

func (rule PatternRule) Matches() bool

Matches determines if the event passed to the function is a match for the pattern rule

func (PatternRule) Targets

func (rule PatternRule) Targets() []RuleTarget

Targets returns the list of registered targets for this particular rule

func (PatternRule) ToJSON

func (rule PatternRule) ToJSON() string

ToJSON returns the JSON string for the rule

func (PatternRule) ToYAML

func (rule PatternRule) ToYAML() (string, error)

ToYAML returns the YAML string for the rule

func (PatternRule) Type

func (rule PatternRule) Type() string

Type returns the rule type for this particular rule (PATTERN)

func (*PatternRule) UnmarshalJSON

func (rule *PatternRule) UnmarshalJSON(data []byte) error

UnmarshalJSON is a method implemented allowing de-serialization of the PatternRule JSON to a PatternRule

type Rule

type Rule interface {
	Type() RuleType
	Matches() bool
	Targets()
	AddTarget() error
}

Rule is an interface that defines a Rule and establishes the different functions that can be execute against a rule to determine if it matches an event

type RuleTarget

type RuleTarget struct {
	TargetURL string `json:"targeturl" yaml:"targeturl"`
}

RuleTarget defines the target for an event that has a matching rule

func NewRuleTarget

func NewRuleTarget(targetURL string) RuleTarget

NewRuleTarget creates and returns a new RuleTarget with the passed in target URL

type RuleType

type RuleType int

RuleType represents an enumeration of the different types of rules that are allowed by the rules engine

const (
	// PATTERN represents a rule that matches a pattern based on the different
	// fields of an EDA event
	PATTERN RuleType = iota
	// NOOP represents a rule that has no impact on any events and is ignored by the
	// rules engine during processing
	NOOP
)

func RuleTypeFromString

func RuleTypeFromString(ruleTypeString string) RuleType

RuleTypeFromString converts a string to the appropriate RuleType. If not found, a default of 'NOOP' is returned

func (RuleType) String

func (ruleType RuleType) String() string

String retruns the string representation of the current RuleType

type RulesEngine

type RulesEngine struct {
	Rules         []Rule
	Configuration dataaccess.DataSourceConfiguration
	// contains filtered or unexported fields
}

RulesEngine is the piece of functionality that determines if a specific rule applies to an event being evaluated

func NewRulesEngine

func NewRulesEngine(configuration dataaccess.DataSourceConfiguration) *RulesEngine

NewRulesEngine creates and returns a reference to a new rules engine object

Directories

Path Synopsis
********************************************************************************** The MIT License (MIT) Copyright (c) 2022 Sean Beard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
********************************************************************************** The MIT License (MIT) Copyright (c) 2022 Sean Beard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

Jump to

Keyboard shortcuts

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