2025-05-20 09:40:15 +00:00
|
|
|
// Copyright 2025 Cloudbase Solutions SRL
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
|
// not use this file except in compliance with the License. You may obtain
|
|
|
|
|
// a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
|
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
|
// License for the specific language governing permissions and limitations
|
|
|
|
|
// under the License.
|
|
|
|
|
|
2024-04-03 14:46:32 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
ErrProducerClosed = fmt.Errorf("producer is closed")
|
|
|
|
|
ErrProducerTimeoutErr = fmt.Errorf("producer timeout error")
|
|
|
|
|
ErrProducerAlreadyRegistered = fmt.Errorf("producer already registered")
|
|
|
|
|
ErrConsumerAlreadyRegistered = fmt.Errorf("consumer already registered")
|
|
|
|
|
ErrWatcherAlreadyStarted = fmt.Errorf("watcher already started")
|
|
|
|
|
ErrWatcherNotInitialized = fmt.Errorf("watcher not initialized")
|
2024-07-04 10:59:02 +00:00
|
|
|
ErrInvalidOperationType = fmt.Errorf("invalid operation")
|
Add events websocket endpoint
This change adds a new websocket endpoint for database events. The events
endpoint allows clients to stream events as they happen in GARM. Events
are defined as a structure containning the event type (create, update, delete),
the database entity involved (instances, pools, repos, etc) and the payload
consisting of the object involved in the event. The payload translates
to the types normally returned by the API and can be deserialized as one
of the types present in the params package.
The events endpoint is a websocket endpoint and it accepts filters as
a simple json send over the websocket connection. The filters allows the
user to specify which entities are of interest, and which operations should
be returned. For example, you may be interested in changes made to pools
or runners, in which case you could create a filter that only returns
update operations for pools. Or update and delete operations.
The filters can be defined as:
{
"filters": [
{
"entity_type": "instance",
"operations": ["update", "delete"]
},
{
"entity_type": "pool"
},
],
"send_everything": false
}
This would return only update and delete events for instances and all events
for pools. Alternatively you can ask GARM to send you everything:
{
"send_everything": true
}
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-07-03 22:30:41 +00:00
|
|
|
ErrInvalidEntityType = fmt.Errorf("invalid entity type")
|
2024-07-04 10:59:02 +00:00
|
|
|
ErrNoFiltersProvided = fmt.Errorf("no filters provided")
|
2024-04-03 14:46:32 +00:00
|
|
|
)
|