This repository has been archived by the owner on Sep 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add package and API skeleton for internal queue (#40)
- Loading branch information
Showing
5 changed files
with
84 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package queue | ||
|
||
import ( | ||
"fmt" | ||
|
||
beatsqueue "github.com/elastic/beats/v7/libbeat/publisher/queue" | ||
|
||
"github.com/elastic/elastic-agent-shipper/api" | ||
) | ||
|
||
// Queue is a shipper-specific wrapper around the bare libbeat queue. | ||
// It accepts api.Event instead of bare interface pointers like the | ||
// libbeat queue, and it sets opinionated defaults for the queue | ||
// semantics. The intention is to keep the shipper from becoming too | ||
// entangled with the legacy queue api, and to gradually expose more | ||
// features as the libbeat queue evolves and we decide what we want | ||
// to support in the shipper. | ||
type Queue struct { | ||
eventQueue beatsqueue.Queue | ||
|
||
//producer beatsqueue.Producer | ||
} | ||
|
||
type Metrics beatsqueue.Metrics | ||
|
||
// metricsSource is a wrapper around the libbeat queue interface, exposing only | ||
// the callback to query the current metrics. It is used to pass queue metrics | ||
// to the monitoring package. | ||
type MetricsSource interface { | ||
Metrics() (Metrics, error) | ||
} | ||
|
||
func New() (*Queue, error) { | ||
return &Queue{}, nil | ||
} | ||
|
||
func (queue *Queue) Publish(event *api.Event) error { | ||
return fmt.Errorf("couldn't publish: Queue.Publish is not implemented") | ||
} | ||
|
||
func (queue *Queue) Metrics() (Metrics, error) { | ||
metrics, err := queue.eventQueue.Metrics() | ||
// We need to do the explicit cast, otherwise this isn't recognized as the same type | ||
return Metrics(metrics), err | ||
} | ||
|
||
func (queue *Queue) Close() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters