From c61ce22b7adf08da487c1cafbe598a1840bb22da Mon Sep 17 00:00:00 2001 From: Stefan Majer Date: Wed, 22 Mar 2023 07:39:53 +0100 Subject: [PATCH] Migrate to buf build (#29) --- .github/workflows/master.yml | 6 +- .github/workflows/pr.yml | 8 +- .github/workflows/release.yaml | 6 +- Dockerfile | 4 +- Dockerfile.client | 2 +- Makefile | 3 +- api/proto/droptailer.pb.go | 229 +++++++++++++++++++++ api/proto/droptailer_grpc.pb.go | 107 ++++++++++ go.mod | 18 +- go.sum | 35 ++-- pkg/client/client.go | 2 +- pkg/client/forwarder.go | 2 +- pkg/server/push.go | 2 +- proto/Makefile | 19 ++ proto/buf.gen.yaml | 14 ++ proto/buf.yaml | 7 + proto/droptailer.pb.go | 306 ----------------------------- proto/{ => proto}/droptailer.proto | 10 +- server/main.go | 2 +- 19 files changed, 425 insertions(+), 357 deletions(-) create mode 100644 api/proto/droptailer.pb.go create mode 100644 api/proto/droptailer_grpc.pb.go create mode 100644 proto/Makefile create mode 100644 proto/buf.gen.yaml create mode 100644 proto/buf.yaml delete mode 100644 proto/droptailer.pb.go rename proto/{ => proto}/droptailer.proto (58%) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index baa594a..10b8e96 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -9,18 +9,18 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install libsystemd headers run: sudo apt-get update && sudo apt-get install libsystemd-dev - name: Lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v3 with: args: -p bugs -p unused --timeout=3m - name: Docker Login - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ${{ secrets.DOCKER_REGISTRY }} username: ${{ secrets.DOCKER_REGISTRY_USER }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 9c12da6..6e63c41 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -9,14 +9,14 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Figure out if running fork PR id: fork run: '["${{ secrets.DOCKER_REGISTRY_TOKEN }}" == ""] && echo "::set-output name=is_fork_pr::true" || echo "::set-output name=is_fork_pr::false"' - name: Docker Login - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ${{ secrets.DOCKER_REGISTRY }} username: ${{ secrets.DOCKER_REGISTRY_USER }} @@ -27,12 +27,12 @@ jobs: run: sudo apt-get update && sudo apt-get install libsystemd-dev - name: Lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v3 with: args: -p bugs -p unused --timeout=3m - name: Docker Login - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ${{ secrets.DOCKER_REGISTRY }} username: ${{ secrets.DOCKER_REGISTRY_USER }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7cf1aa4..deb6985 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,18 +9,18 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install libsystemd headers run: sudo apt-get update && sudo apt-get install libsystemd-dev - name: Lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v3 with: args: -p bugs -p unused --timeout=3m - name: Docker Login - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ${{ secrets.DOCKER_REGISTRY }} username: ${{ secrets.DOCKER_REGISTRY_USER }} diff --git a/Dockerfile b/Dockerfile index 8ab8220..f88dec6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM golang:1.19-buster as builder +FROM golang:1.20-buster as builder COPY / /work WORKDIR /work RUN make server -FROM alpine:3.16 +FROM alpine:3.17 COPY --from=builder /work/bin/server /server ENV SERVER_PORT=50051 EXPOSE ${SERVER_PORT} diff --git a/Dockerfile.client b/Dockerfile.client index 88c1e92..54a687d 100644 --- a/Dockerfile.client +++ b/Dockerfile.client @@ -1,4 +1,4 @@ -FROM golang:1.19-buster as builder +FROM golang:1.20-buster as builder COPY / /work WORKDIR /work RUN apt-get update \ diff --git a/Makefile b/Makefile index 468f569..1d8fe7c 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,7 @@ DOCKER_TAG := $(or ${GITHUB_TAG_NAME}, latest) .PHONY: proto proto: - docker pull metalstack/builder - docker run -it --rm --user $$(id -u):$$(id -g) -v ${PWD}/proto:/work/proto metalstack/builder protoc -I proto/ proto/droptailer.proto --go_out=plugins=grpc:proto + make -C proto protoc .PHONY: server server: diff --git a/api/proto/droptailer.pb.go b/api/proto/droptailer.pb.go new file mode 100644 index 0000000..d571a3e --- /dev/null +++ b/api/proto/droptailer.pb.go @@ -0,0 +1,229 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc (unknown) +// source: proto/droptailer.proto + +package proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Drop struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Fields map[string]string `protobuf:"bytes,2,rep,name=fields,proto3" json:"fields,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *Drop) Reset() { + *x = Drop{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_droptailer_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Drop) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Drop) ProtoMessage() {} + +func (x *Drop) ProtoReflect() protoreflect.Message { + mi := &file_proto_droptailer_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Drop.ProtoReflect.Descriptor instead. +func (*Drop) Descriptor() ([]byte, []int) { + return file_proto_droptailer_proto_rawDescGZIP(), []int{0} +} + +func (x *Drop) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +func (x *Drop) GetFields() map[string]string { + if x != nil { + return x.Fields + } + return nil +} + +type Void struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *Void) Reset() { + *x = Void{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_droptailer_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Void) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Void) ProtoMessage() {} + +func (x *Void) ProtoReflect() protoreflect.Message { + mi := &file_proto_droptailer_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Void.ProtoReflect.Descriptor instead. +func (*Void) Descriptor() ([]byte, []int) { + return file_proto_droptailer_proto_rawDescGZIP(), []int{1} +} + +var File_proto_droptailer_proto protoreflect.FileDescriptor + +var file_proto_droptailer_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x64, 0x72, 0x6f, 0x70, 0x74, 0x61, 0x69, 0x6c, + 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0xac, 0x01, 0x0a, 0x04, 0x44, 0x72, 0x6f, 0x70, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x12, 0x2f, 0x0a, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x72, 0x6f, 0x70, + 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x66, 0x69, + 0x65, 0x6c, 0x64, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, + 0x06, 0x0a, 0x04, 0x56, 0x6f, 0x69, 0x64, 0x32, 0x30, 0x0a, 0x0a, 0x44, 0x72, 0x6f, 0x70, 0x74, + 0x61, 0x69, 0x6c, 0x65, 0x72, 0x12, 0x22, 0x0a, 0x04, 0x50, 0x75, 0x73, 0x68, 0x12, 0x0b, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x1a, 0x0b, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x56, 0x6f, 0x69, 0x64, 0x22, 0x00, 0x42, 0x7d, 0x0a, 0x09, 0x63, 0x6f, 0x6d, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x0f, 0x44, 0x72, 0x6f, 0x70, 0x74, 0x61, 0x69, 0x6c, + 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x2d, 0x73, 0x74, 0x61, 0x63, + 0x6b, 0x2f, 0x64, 0x72, 0x6f, 0x70, 0x74, 0x61, 0x69, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0xa2, 0x02, 0x03, 0x50, 0x58, 0x58, 0xaa, 0x02, 0x05, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0xca, 0x02, 0x05, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0xe2, 0x02, 0x11, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x05, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_proto_droptailer_proto_rawDescOnce sync.Once + file_proto_droptailer_proto_rawDescData = file_proto_droptailer_proto_rawDesc +) + +func file_proto_droptailer_proto_rawDescGZIP() []byte { + file_proto_droptailer_proto_rawDescOnce.Do(func() { + file_proto_droptailer_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_droptailer_proto_rawDescData) + }) + return file_proto_droptailer_proto_rawDescData +} + +var file_proto_droptailer_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_proto_droptailer_proto_goTypes = []interface{}{ + (*Drop)(nil), // 0: proto.Drop + (*Void)(nil), // 1: proto.Void + nil, // 2: proto.Drop.FieldsEntry + (*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp +} +var file_proto_droptailer_proto_depIdxs = []int32{ + 3, // 0: proto.Drop.timestamp:type_name -> google.protobuf.Timestamp + 2, // 1: proto.Drop.fields:type_name -> proto.Drop.FieldsEntry + 0, // 2: proto.Droptailer.Push:input_type -> proto.Drop + 1, // 3: proto.Droptailer.Push:output_type -> proto.Void + 3, // [3:4] is the sub-list for method output_type + 2, // [2:3] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_proto_droptailer_proto_init() } +func file_proto_droptailer_proto_init() { + if File_proto_droptailer_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_proto_droptailer_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Drop); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_droptailer_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Void); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_proto_droptailer_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_proto_droptailer_proto_goTypes, + DependencyIndexes: file_proto_droptailer_proto_depIdxs, + MessageInfos: file_proto_droptailer_proto_msgTypes, + }.Build() + File_proto_droptailer_proto = out.File + file_proto_droptailer_proto_rawDesc = nil + file_proto_droptailer_proto_goTypes = nil + file_proto_droptailer_proto_depIdxs = nil +} diff --git a/api/proto/droptailer_grpc.pb.go b/api/proto/droptailer_grpc.pb.go new file mode 100644 index 0000000..7b5f38a --- /dev/null +++ b/api/proto/droptailer_grpc.pb.go @@ -0,0 +1,107 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: proto/droptailer.proto + +package proto + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + Droptailer_Push_FullMethodName = "/proto.Droptailer/Push" +) + +// DroptailerClient is the client API for Droptailer service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type DroptailerClient interface { + Push(ctx context.Context, in *Drop, opts ...grpc.CallOption) (*Void, error) +} + +type droptailerClient struct { + cc grpc.ClientConnInterface +} + +func NewDroptailerClient(cc grpc.ClientConnInterface) DroptailerClient { + return &droptailerClient{cc} +} + +func (c *droptailerClient) Push(ctx context.Context, in *Drop, opts ...grpc.CallOption) (*Void, error) { + out := new(Void) + err := c.cc.Invoke(ctx, Droptailer_Push_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// DroptailerServer is the server API for Droptailer service. +// All implementations should embed UnimplementedDroptailerServer +// for forward compatibility +type DroptailerServer interface { + Push(context.Context, *Drop) (*Void, error) +} + +// UnimplementedDroptailerServer should be embedded to have forward compatible implementations. +type UnimplementedDroptailerServer struct { +} + +func (UnimplementedDroptailerServer) Push(context.Context, *Drop) (*Void, error) { + return nil, status.Errorf(codes.Unimplemented, "method Push not implemented") +} + +// UnsafeDroptailerServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to DroptailerServer will +// result in compilation errors. +type UnsafeDroptailerServer interface { + mustEmbedUnimplementedDroptailerServer() +} + +func RegisterDroptailerServer(s grpc.ServiceRegistrar, srv DroptailerServer) { + s.RegisterService(&Droptailer_ServiceDesc, srv) +} + +func _Droptailer_Push_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Drop) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DroptailerServer).Push(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Droptailer_Push_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DroptailerServer).Push(ctx, req.(*Drop)) + } + return interceptor(ctx, in, info, handler) +} + +// Droptailer_ServiceDesc is the grpc.ServiceDesc for Droptailer service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Droptailer_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "proto.Droptailer", + HandlerType: (*DroptailerServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Push", + Handler: _Droptailer_Push_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "proto/droptailer.proto", +} diff --git a/go.mod b/go.mod index 0895767..98075aa 100644 --- a/go.mod +++ b/go.mod @@ -1,18 +1,18 @@ module github.com/metal-pod/droptailer -go 1.18 +go 1.20 require ( - github.com/coreos/go-systemd/v22 v22.3.2 + github.com/coreos/go-systemd/v22 v22.5.0 github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 - google.golang.org/grpc v1.49.0 - google.golang.org/protobuf v1.28.1 + google.golang.org/grpc v1.53.0 + google.golang.org/protobuf v1.29.0 ) require ( - github.com/golang/protobuf v1.5.2 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect - google.golang.org/genproto v0.0.0-20220902135211-223410557253 // indirect + github.com/golang/protobuf v1.5.3 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect + google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect ) diff --git a/go.sum b/go.sum index fb7127a..48aaab1 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= -github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -23,11 +23,11 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -67,8 +67,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -80,12 +80,12 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -97,26 +97,25 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20220902135211-223410557253 h1:vXJMM8Shg7TGaYxZsQ++A/FOSlbDmDtWhS/o+3w/hj4= -google.golang.org/genproto v0.0.0-20220902135211-223410557253/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= +google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA= +google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.49.0 h1:WTLtQzmQori5FUH25Pq4WT22oCsv8USpQ+F6rqtsmxw= -google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= +google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= +google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.29.0 h1:44S3JjaKmLEE4YIkjzexaP+NzZsudE3Zin5Njn/pYX0= +google.golang.org/protobuf v1.29.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/pkg/client/client.go b/pkg/client/client.go index 3eed1f1..67bd592 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -10,7 +10,7 @@ import ( "github.com/coreos/go-systemd/v22/sdjournal" grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry" - pb "github.com/metal-pod/droptailer/proto" + pb "github.com/metal-pod/droptailer/api/proto" "google.golang.org/grpc" "google.golang.org/grpc/credentials" diff --git a/pkg/client/forwarder.go b/pkg/client/forwarder.go index a350616..ff64811 100644 --- a/pkg/client/forwarder.go +++ b/pkg/client/forwarder.go @@ -12,7 +12,7 @@ import ( "github.com/coreos/go-systemd/v22/sdjournal" grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry" - pb "github.com/metal-pod/droptailer/proto" + pb "github.com/metal-pod/droptailer/api/proto" "google.golang.org/protobuf/types/known/timestamppb" ) diff --git a/pkg/server/push.go b/pkg/server/push.go index ed848c7..8e7e9f7 100644 --- a/pkg/server/push.go +++ b/pkg/server/push.go @@ -6,7 +6,7 @@ import ( "fmt" "time" - pb "github.com/metal-pod/droptailer/proto" + pb "github.com/metal-pod/droptailer/api/proto" ) const ( diff --git a/proto/Makefile b/proto/Makefile new file mode 100644 index 0000000..10a35ec --- /dev/null +++ b/proto/Makefile @@ -0,0 +1,19 @@ +MAKEFLAGS += --no-print-directory +BUF_VERSION := 1.15.0 + +_buf: + docker run --rm \ + --entrypoint sh \ + -v $(PWD)/..:/workspace \ + -w /workspace/proto \ + bufbuild/buf:$(BUF_VERSION) \ + -c "buf $(CMD) && chown -R $(shell id -u):$(shell id -g) /workspace" + +.PHONY: protolint +protolint: + @$(MAKE) _buf CMD="format -w proto" + @$(MAKE) _buf CMD="lint -v" + +.PHONY: protoc +protoc: protolint + @$(MAKE) _buf CMD="generate -v" diff --git a/proto/buf.gen.yaml b/proto/buf.gen.yaml new file mode 100644 index 0000000..6377dc2 --- /dev/null +++ b/proto/buf.gen.yaml @@ -0,0 +1,14 @@ +version: v1 +managed: + enabled: true + go_package_prefix: + default: github.com/metal-stack/droptailer/api +plugins: + # generate go structs for protocol buffer definition + - plugin: buf.build/protocolbuffers/go:v1.28.1 + out: ../api + opt: paths=source_relative + - plugin: buf.build/grpc/go:v1.3.0 + out: ../api + opt: paths=source_relative,require_unimplemented_servers=false + diff --git a/proto/buf.yaml b/proto/buf.yaml new file mode 100644 index 0000000..d4ff52d --- /dev/null +++ b/proto/buf.yaml @@ -0,0 +1,7 @@ +version: v1 +breaking: + use: + - FILE +lint: + use: + - BASIC diff --git a/proto/droptailer.pb.go b/proto/droptailer.pb.go deleted file mode 100644 index 01c0bdc..0000000 --- a/proto/droptailer.pb.go +++ /dev/null @@ -1,306 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.26.0 -// protoc v3.20.1 -// source: droptailer.proto - -package proto - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Drop struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Fields map[string]string `protobuf:"bytes,2,rep,name=fields,proto3" json:"fields,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *Drop) Reset() { - *x = Drop{} - if protoimpl.UnsafeEnabled { - mi := &file_droptailer_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Drop) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Drop) ProtoMessage() {} - -func (x *Drop) ProtoReflect() protoreflect.Message { - mi := &file_droptailer_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Drop.ProtoReflect.Descriptor instead. -func (*Drop) Descriptor() ([]byte, []int) { - return file_droptailer_proto_rawDescGZIP(), []int{0} -} - -func (x *Drop) GetTimestamp() *timestamppb.Timestamp { - if x != nil { - return x.Timestamp - } - return nil -} - -func (x *Drop) GetFields() map[string]string { - if x != nil { - return x.Fields - } - return nil -} - -type Void struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *Void) Reset() { - *x = Void{} - if protoimpl.UnsafeEnabled { - mi := &file_droptailer_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Void) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Void) ProtoMessage() {} - -func (x *Void) ProtoReflect() protoreflect.Message { - mi := &file_droptailer_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Void.ProtoReflect.Descriptor instead. -func (*Void) Descriptor() ([]byte, []int) { - return file_droptailer_proto_rawDescGZIP(), []int{1} -} - -var File_droptailer_proto protoreflect.FileDescriptor - -var file_droptailer_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x64, 0x72, 0x6f, 0x70, 0x74, 0x61, 0x69, 0x6c, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xac, 0x01, 0x0a, 0x04, 0x44, - 0x72, 0x6f, 0x70, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2f, 0x0a, - 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x1a, 0x39, - 0x0a, 0x0b, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, - 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, - 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x06, 0x0a, 0x04, 0x56, 0x6f, 0x69, - 0x64, 0x32, 0x30, 0x0a, 0x0a, 0x44, 0x72, 0x6f, 0x70, 0x74, 0x61, 0x69, 0x6c, 0x65, 0x72, 0x12, - 0x22, 0x0a, 0x04, 0x50, 0x75, 0x73, 0x68, 0x12, 0x0b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x44, 0x72, 0x6f, 0x70, 0x1a, 0x0b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x56, 0x6f, 0x69, - 0x64, 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_droptailer_proto_rawDescOnce sync.Once - file_droptailer_proto_rawDescData = file_droptailer_proto_rawDesc -) - -func file_droptailer_proto_rawDescGZIP() []byte { - file_droptailer_proto_rawDescOnce.Do(func() { - file_droptailer_proto_rawDescData = protoimpl.X.CompressGZIP(file_droptailer_proto_rawDescData) - }) - return file_droptailer_proto_rawDescData -} - -var file_droptailer_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_droptailer_proto_goTypes = []interface{}{ - (*Drop)(nil), // 0: proto.Drop - (*Void)(nil), // 1: proto.Void - nil, // 2: proto.Drop.FieldsEntry - (*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp -} -var file_droptailer_proto_depIdxs = []int32{ - 3, // 0: proto.Drop.timestamp:type_name -> google.protobuf.Timestamp - 2, // 1: proto.Drop.fields:type_name -> proto.Drop.FieldsEntry - 0, // 2: proto.Droptailer.Push:input_type -> proto.Drop - 1, // 3: proto.Droptailer.Push:output_type -> proto.Void - 3, // [3:4] is the sub-list for method output_type - 2, // [2:3] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_droptailer_proto_init() } -func file_droptailer_proto_init() { - if File_droptailer_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_droptailer_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Drop); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_droptailer_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Void); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_droptailer_proto_rawDesc, - NumEnums: 0, - NumMessages: 3, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_droptailer_proto_goTypes, - DependencyIndexes: file_droptailer_proto_depIdxs, - MessageInfos: file_droptailer_proto_msgTypes, - }.Build() - File_droptailer_proto = out.File - file_droptailer_proto_rawDesc = nil - file_droptailer_proto_goTypes = nil - file_droptailer_proto_depIdxs = nil -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConnInterface - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 - -// DroptailerClient is the client API for Droptailer service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type DroptailerClient interface { - Push(ctx context.Context, in *Drop, opts ...grpc.CallOption) (*Void, error) -} - -type droptailerClient struct { - cc grpc.ClientConnInterface -} - -func NewDroptailerClient(cc grpc.ClientConnInterface) DroptailerClient { - return &droptailerClient{cc} -} - -func (c *droptailerClient) Push(ctx context.Context, in *Drop, opts ...grpc.CallOption) (*Void, error) { - out := new(Void) - err := c.cc.Invoke(ctx, "/proto.Droptailer/Push", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// DroptailerServer is the server API for Droptailer service. -type DroptailerServer interface { - Push(context.Context, *Drop) (*Void, error) -} - -// UnimplementedDroptailerServer can be embedded to have forward compatible implementations. -type UnimplementedDroptailerServer struct { -} - -func (*UnimplementedDroptailerServer) Push(context.Context, *Drop) (*Void, error) { - return nil, status.Errorf(codes.Unimplemented, "method Push not implemented") -} - -func RegisterDroptailerServer(s *grpc.Server, srv DroptailerServer) { - s.RegisterService(&_Droptailer_serviceDesc, srv) -} - -func _Droptailer_Push_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Drop) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DroptailerServer).Push(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.Droptailer/Push", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DroptailerServer).Push(ctx, req.(*Drop)) - } - return interceptor(ctx, in, info, handler) -} - -var _Droptailer_serviceDesc = grpc.ServiceDesc{ - ServiceName: "proto.Droptailer", - HandlerType: (*DroptailerServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Push", - Handler: _Droptailer_Push_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "droptailer.proto", -} diff --git a/proto/droptailer.proto b/proto/proto/droptailer.proto similarity index 58% rename from proto/droptailer.proto rename to proto/proto/droptailer.proto index 6bbebb4..df1b4ba 100644 --- a/proto/droptailer.proto +++ b/proto/proto/droptailer.proto @@ -2,17 +2,17 @@ syntax = "proto3"; package proto; -option go_package = "./;proto"; - import "google/protobuf/timestamp.proto"; +option go_package = "./;proto"; + service Droptailer { - rpc Push (Drop) returns (Void) {}; + rpc Push(Drop) returns (Void) {} } message Drop { - google.protobuf.Timestamp timestamp = 1; - map fields = 2; + google.protobuf.Timestamp timestamp = 1; + map fields = 2; } message Void {} diff --git a/server/main.go b/server/main.go index 87d3ab5..a503634 100644 --- a/server/main.go +++ b/server/main.go @@ -6,7 +6,7 @@ import ( "net" "os" - pb "github.com/metal-pod/droptailer/proto" + pb "github.com/metal-pod/droptailer/api/proto" server "github.com/metal-pod/droptailer/pkg/server" "google.golang.org/grpc"