Documentation ¶
Index ¶
- Constants
- Variables
- func Register(name string, initFunc InitFunc) error
- func Shutdown()
- type Alert
- type AlertWatcherFunc
- type InitFunc
- type KvAlert
- func (kva *KvAlert) Clear(resourceType api.ResourceType, alertID int64, ttl uint64) error
- func (kva *KvAlert) ClearByUniqueTag(resourceType api.ResourceType, resourceId string, uniqueTag string, ttl uint64) error
- func (kva *KvAlert) Enumerate(filter *api.Alert) ([]*api.Alert, error)
- func (kva *KvAlert) EnumerateWithinTimeRange(timeStart time.Time, timeEnd time.Time, resourceType api.ResourceType) ([]*api.Alert, error)
- func (kva *KvAlert) Erase(resourceType api.ResourceType, alertID int64) error
- func (kva *KvAlert) GetKvdbInstance() kvdb.Kvdb
- func (kva *KvAlert) Raise(a *api.Alert) error
- func (kva *KvAlert) RaiseIfNotExist(a *api.Alert) error
- func (kva *KvAlert) Retrieve(resourceType api.ResourceType, alertID int64) (*api.Alert, error)
- func (kva *KvAlert) Shutdown()
- func (kva *KvAlert) String() string
- func (kva *KvAlert) Subscribe(parentAlertType int64, childAlert *api.Alert) error
- func (kva *KvAlert) Watch(clusterID string, alertWatcherFunc AlertWatcherFunc) error
Constants ¶
const ( // Name of this alert client implementation. Name = "alert_kvdb" // NameTest of this alert instance used only for unit tests. NameTest = "alert_kvdb_test" )
Variables ¶
var ( // ErrNotSupported implemenation of a specific function is not supported. ErrNotSupported = errors.New("Implementation not supported") // ErrNotFound raised if Key is not found. ErrNotFound = errors.New("Key not found") // ErrExist raised if key already exists. ErrExist = errors.New("Key already exists") // ErrUnmarshal raised if Get fails to unmarshal value. ErrUnmarshal = errors.New("Failed to unmarshal value") // ErrIllegal raised if object is not valid. ErrIllegal = errors.New("Illegal operation") // ErrNotInitialized raised if alert not initialized. ErrNotInitialized = errors.New("Alert not initialized") // ErrAlertClientNotFound raised if no client implementation found. ErrAlertClientNotFound = errors.New("Alert client not found") // ErrResourceNotFound raised if ResourceType is not found> ErrResourceNotFound = errors.New("Resource not found in Alert") // ErrSubscribedRaise raised if unable to raise a subscribed alert ErrSubscribedRaise = errors.New("Could not raise alert and its subscribed alerts") )
Functions ¶
Types ¶
type Alert ¶
type Alert interface { fmt.Stringer // Shutdown. Shutdown() // GetKvdbInstance. GetKvdbInstance() kvdb.Kvdb // Raise raises an Alert. Raise(alert *api.Alert) error // Raise raises an Alert only if another alert with given resource type, // resource id, and unqiue_tage doesnt exists already. RaiseIfNotExist(alert *api.Alert) error // Subscribe allows a child (dependent) alert to subscribe to a parent alert Subscribe(parentAlertType int64, childAlert *api.Alert) error // Retrieve retrieves specific Alert. Retrieve(resourceType api.ResourceType, id int64) (*api.Alert, error) // Enumerate enumerates Alert. Enumerate(filter *api.Alert) ([]*api.Alert, error) // EnumerateWithinTimeRange enumerates Alert between timeStart and timeEnd. EnumerateWithinTimeRange( timeStart time.Time, timeEnd time.Time, resourceType api.ResourceType, ) ([]*api.Alert, error) // Erase erases an Alert. Erase(resourceType api.ResourceType, alertID int64) error // Clear an Alert. Clear(resourceType api.ResourceType, alertID int64, ttl uint64) error // Clear an Alert for a resource with unique tag. ClearByUniqueTag( resourceType api.ResourceType, resourceId string, uniqueTag string, ttl uint64, ) error // Watch on all Alerts for the given clusterID. It uses the global kvdb // options provided while creating the alertClient object to access this // cluster Watch(clusterID string, alertWatcher AlertWatcherFunc) error }
Alert interface for Alert API.
type AlertWatcherFunc ¶
AlertWatcherFunc is a function type used as a callback for KV WatchTree.
type KvAlert ¶
type KvAlert struct {
// contains filtered or unexported fields
}
KvAlert is used for managing the alerts and its kvdb instance
func (*KvAlert) ClearByUniqueTag ¶
func (*KvAlert) EnumerateWithinTimeRange ¶
func (kva *KvAlert) EnumerateWithinTimeRange( timeStart time.Time, timeEnd time.Time, resourceType api.ResourceType, ) ([]*api.Alert, error)
EnumerateWithinTimeRange enumerates alert between timeStart and timeEnd.
func (*KvAlert) Erase ¶
func (kva *KvAlert) Erase(resourceType api.ResourceType, alertID int64) error
Erase erases an alert.
func (*KvAlert) GetKvdbInstance ¶
GetKvdbInstance returns a kvdb instance associated with this alert client and clusterID combination.
func (*KvAlert) RaiseIfNotExist ¶
Raise raises an Alert if does not exists yet.
func (*KvAlert) Subscribe ¶
Subscribe allows a child (dependent) alert to subscribe to a parent alert
func (*KvAlert) Watch ¶
func (kva *KvAlert) Watch(clusterID string, alertWatcherFunc AlertWatcherFunc) error
Watch on all Alerts for the given clusterID. It uses the global kvdb options provided while creating the alertClient object to access this cluster This way we ensure that the caller of the api is able to watch alerts on clusters that it is authorized for.