Merge pull request #3204 from crosbymichael/fix-forward
Fix API forward events for shims
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
api "github.com/containerd/containerd/api/services/ttrpc/events/v1"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/events"
|
||||
"github.com/containerd/containerd/events/exchange"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
)
|
||||
@@ -29,10 +30,19 @@ type ttrpcService struct {
|
||||
events *exchange.Exchange
|
||||
}
|
||||
|
||||
func (s *ttrpcService) Publish(ctx context.Context, r *api.PublishRequest) (*ptypes.Empty, error) {
|
||||
if err := s.events.Publish(ctx, r.Topic, r.Event); err != nil {
|
||||
func (s *ttrpcService) Forward(ctx context.Context, r *api.ForwardRequest) (*ptypes.Empty, error) {
|
||||
if err := s.events.Forward(ctx, fromTProto(r.Envelope)); err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
}
|
||||
|
||||
return &ptypes.Empty{}, nil
|
||||
}
|
||||
|
||||
func fromTProto(env *api.Envelope) *events.Envelope {
|
||||
return &events.Envelope{
|
||||
Timestamp: env.Timestamp,
|
||||
Namespace: env.Namespace,
|
||||
Topic: env.Topic,
|
||||
Event: env.Event,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user