api/events: split event types from events service
To avoid importing all of grpc when consuming events, the types of events have been split in to a separate package. This should allow a reduction in memory usage in cases where a package is consuming events but not using the gprc service directly. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
eventstypes "github.com/containerd/containerd/api/events"
|
||||
v1 "github.com/containerd/containerd/api/services/events/v1"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/events"
|
||||
@@ -19,9 +20,9 @@ import (
|
||||
func TestExchangeBasic(t *testing.T) {
|
||||
ctx := namespaces.WithNamespace(context.Background(), t.Name())
|
||||
testevents := []events.Event{
|
||||
&v1.ContainerCreate{ID: "asdf"},
|
||||
&v1.ContainerCreate{ID: "qwer"},
|
||||
&v1.ContainerCreate{ID: "zxcv"},
|
||||
&eventstypes.ContainerCreate{ID: "asdf"},
|
||||
&eventstypes.ContainerCreate{ID: "qwer"},
|
||||
&eventstypes.ContainerCreate{ID: "zxcv"},
|
||||
}
|
||||
exchange := NewExchange()
|
||||
|
||||
@@ -80,7 +81,7 @@ func TestExchangeBasic(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
received = append(received, ev.(*v1.ContainerCreate))
|
||||
received = append(received, ev.(*eventstypes.ContainerCreate))
|
||||
case err := <-subscriber.errq:
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -118,7 +119,7 @@ func TestExchangeValidateTopic(t *testing.T) {
|
||||
},
|
||||
} {
|
||||
t.Run(testcase.input, func(t *testing.T) {
|
||||
event := &v1.ContainerCreate{ID: t.Name()}
|
||||
event := &eventstypes.ContainerCreate{ID: t.Name()}
|
||||
if err := exchange.Publish(ctx, testcase.input, event); errors.Cause(err) != testcase.err {
|
||||
if err == nil {
|
||||
t.Fatalf("expected error %v, received nil", testcase.err)
|
||||
|
||||
Reference in New Issue
Block a user