pbehavior

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

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

Go to latest
Published: Sep 21, 2020 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PBehaviorCollectionName = "default_pbehavior"
)

PBehaviorCollectionName is where we store pbehaviors

Variables

This section is empty.

Functions

func DefaultCollection

func DefaultCollection(session *mgo.Session) mongo.Collection

Types

type Adapter

type Adapter interface {
	// Get read pbehaviors from db
	Get(bson.M) ([]types.PBehavior, error)

	// Insert insert pbehavior in db
	Insert(types.PBehavior) error

	// Update insert pbehavior in db
	Update(types.PBehavior) error

	// RemoveId remove pbehavior from db by id
	RemoveId(string) error

	// GetByEntityIds get pbehaviors from db by Entity IDs
	GetByEntityIds(eids []string, enabled bool) ([]types.PBehavior, error)
}

func NewAdapter

func NewAdapter(collection mongo.Collection) Adapter

NewAdapter gives the correct mongo pbehavior adapter.

type Service

type Service interface {
	// Create declare a new pbheavior
	Insert(types.PBehavior) error

	// Get find pbehaviors from db
	Get(bson.M) ([]types.PBehavior, error)

	// Remove remove a pbehavior
	Remove(types.PBehavior) error

	// AlarmHasPBehavior checks if an alarm has an enabled pbehavior on it. Be
	// careful, this method does not check if a pbehavior is active.
	AlarmHasPBehavior(types.Alarm) bool

	// GetByEntityIds retrieves every pbehaviors on a list of entities
	GetByEntityIds(eids []string, enabled bool) ([]types.PBehavior, error)

	// HasActivePBehavior returns true if the entity has an active pbehavior.
	HasActivePBehavior(entityID string) bool
}

Service allows you to manipulate actions.

func NewService

func NewService(pbehaviorAdapter Adapter, logger zerolog.Logger) Service

NewService gives the correct pbehavior adapter.

Jump to

Keyboard shortcuts

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