File diff suppressed because it is too large
Load Diff
55
api/services/ttrpc/events/v1/events_fieldpath.pb.go
Normal file
55
api/services/ttrpc/events/v1/events_fieldpath.pb.go
Normal file
@@ -0,0 +1,55 @@
|
||||
// Code generated by protoc-gen-go-fieldpath. DO NOT EDIT.
|
||||
// source: github.com/containerd/containerd/api/services/ttrpc/events/v1/events.proto
|
||||
package events
|
||||
|
||||
import (
|
||||
typeurl "github.com/containerd/typeurl"
|
||||
)
|
||||
|
||||
// Field returns the value for the given fieldpath as a string, if defined.
|
||||
// If the value is not defined, the second value will be false.
|
||||
func (m *ForwardRequest) Field(fieldpath []string) (string, bool) {
|
||||
if len(fieldpath) == 0 {
|
||||
return "", false
|
||||
}
|
||||
switch fieldpath[0] {
|
||||
case "envelope":
|
||||
// NOTE(stevvooe): This is probably not correct in many cases.
|
||||
// We assume that the target message also implements the Field
|
||||
// method, which isn't likely true in a lot of cases.
|
||||
//
|
||||
// If you have a broken build and have found this comment,
|
||||
// you may be closer to a solution.
|
||||
if m.Envelope == nil {
|
||||
return "", false
|
||||
}
|
||||
return m.Envelope.Field(fieldpath[1:])
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
// Field returns the value for the given fieldpath as a string, if defined.
|
||||
// If the value is not defined, the second value will be false.
|
||||
func (m *Envelope) Field(fieldpath []string) (string, bool) {
|
||||
if len(fieldpath) == 0 {
|
||||
return "", false
|
||||
}
|
||||
switch fieldpath[0] {
|
||||
// unhandled: timestamp
|
||||
case "namespace":
|
||||
return string(m.Namespace), len(m.Namespace) > 0
|
||||
case "topic":
|
||||
return string(m.Topic), len(m.Topic) > 0
|
||||
case "event":
|
||||
decoded, err := typeurl.UnmarshalAny(m.Event)
|
||||
if err != nil {
|
||||
return "", false
|
||||
}
|
||||
adaptor, ok := decoded.(interface{ Field([]string) (string, bool) })
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
return adaptor.Field(fieldpath[1:])
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
45
api/services/ttrpc/events/v1/events_ttrpc.pb.go
Normal file
45
api/services/ttrpc/events/v1/events_ttrpc.pb.go
Normal file
@@ -0,0 +1,45 @@
|
||||
// Code generated by protoc-gen-go-ttrpc. DO NOT EDIT.
|
||||
// source: github.com/containerd/containerd/api/services/ttrpc/events/v1/events.proto
|
||||
package events
|
||||
|
||||
import (
|
||||
context "context"
|
||||
ttrpc "github.com/containerd/ttrpc"
|
||||
empty "github.com/golang/protobuf/ptypes/empty"
|
||||
)
|
||||
|
||||
type EventsService interface {
|
||||
Forward(context.Context, *ForwardRequest) (*empty.Empty, error)
|
||||
}
|
||||
|
||||
func RegisterEventsService(srv *ttrpc.Server, svc EventsService) {
|
||||
srv.RegisterService("containerd.services.events.ttrpc.v1.Events", &ttrpc.ServiceDesc{
|
||||
Methods: map[string]ttrpc.Method{
|
||||
"Forward": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
|
||||
var req ForwardRequest
|
||||
if err := unmarshal(&req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return svc.Forward(ctx, &req)
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
type eventsClient struct {
|
||||
client *ttrpc.Client
|
||||
}
|
||||
|
||||
func NewEventsClient(client *ttrpc.Client) EventsService {
|
||||
return &eventsClient{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *eventsClient) Forward(ctx context.Context, req *ForwardRequest) (*empty.Empty, error) {
|
||||
var resp empty.Empty
|
||||
if err := c.client.Call(ctx, "containerd.services.events.ttrpc.v1.Events", "Forward", req, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
Reference in New Issue
Block a user