Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Okstad <pokstad@gitlab.com>2019-02-25 19:33:05 +0300
committerPaul Okstad <pokstad@gitlab.com>2019-02-27 02:07:36 +0300
commit5e085cdbbeb326cb2e639be57ed6dd4043eb3f69 (patch)
treeb1bf6f54fafbe871edda2edfd40e0b0a5f7c5cb2
parent4640fcfd55ff44a3e6535421dbd40ac192d31473 (diff)
absorb protoc-gen-gitaly
-rw-r--r--cmd/protoc-gen-gitaly/main.go69
-rw-r--r--internal/praefect/pb/linter/lint.go81
-rw-r--r--internal/praefect/pb/linter/lint_test.go67
-rw-r--r--internal/praefect/pb/linter/testdata/incomplete.pb.go68
-rw-r--r--internal/praefect/pb/linter/testdata/incomplete.proto9
-rw-r--r--internal/praefect/pb/linter/testdata/invalid.pb.go69
-rw-r--r--internal/praefect/pb/linter/testdata/invalid.proto10
-rw-r--r--internal/praefect/pb/linter/testdata/valid.pb.go70
-rw-r--r--internal/praefect/pb/linter/testdata/valid.proto11
-rw-r--r--internal/praefect/pb/optype.pb.go124
-rw-r--r--internal/praefect/pb/optype.proto20
11 files changed, 598 insertions, 0 deletions
diff --git a/cmd/protoc-gen-gitaly/main.go b/cmd/protoc-gen-gitaly/main.go
new file mode 100644
index 000000000..3d43a37a1
--- /dev/null
+++ b/cmd/protoc-gen-gitaly/main.go
@@ -0,0 +1,69 @@
+// Command protoc-gen-gitaly is designed to be used as a protobuf compiler
+// plugin to verify Gitaly processes are being followed when writing RPC's.
+//
+// Prerequisites
+//
+// Protobuf compiler:
+// https://github.com/protocolbuffers/protobuf/releases
+//
+// Usage
+//
+// To try out, run the following command while in the project root:
+//
+// protoc --gitaly_out=. -I$(pwd)/pb -I$(pwd)/testdata $(pwd)/testdata/*.proto
+//
+// You should see some errors printed to screen for improperly written
+// RPC's in the testdata/test.proto file.
+package main
+
+import (
+ "io/ioutil"
+ "log"
+ "os"
+ "strings"
+
+ "github.com/golang/protobuf/proto"
+ plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
+ "gitlab.com/gitlab-org/gitaly/internal/praefect/pb/linter"
+)
+
+func main() {
+ data, err := ioutil.ReadAll(os.Stdin)
+ if err != nil {
+ log.Fatalf("reading input: %s", err)
+ }
+
+ req := new(plugin.CodeGeneratorRequest)
+
+ if err := proto.Unmarshal(data, req); err != nil {
+ log.Fatalf("parsing input proto: %s", err)
+ }
+
+ var errMsgs []string
+
+ // lint each requested file
+ for _, pf := range req.GetProtoFile() {
+ errs := linter.LintFile(pf)
+ for _, err := range errs {
+ errMsgs = append(errMsgs, err.Error())
+ }
+ }
+
+ resp := new(plugin.CodeGeneratorResponse)
+
+ if len(errMsgs) > 0 {
+ errMsg := strings.Join(errMsgs, "\n\t")
+ resp.Error = &errMsg
+ }
+
+ // Send back the results.
+ data, err = proto.Marshal(resp)
+ if err != nil {
+ log.Fatalf("failed to marshal output proto: %s", err)
+ }
+
+ _, err = os.Stdout.Write(data)
+ if err != nil {
+ log.Fatalf("failed to write output proto: %s", err)
+ }
+}
diff --git a/internal/praefect/pb/linter/lint.go b/internal/praefect/pb/linter/lint.go
new file mode 100644
index 000000000..667990ec2
--- /dev/null
+++ b/internal/praefect/pb/linter/lint.go
@@ -0,0 +1,81 @@
+package main
+
+import (
+ "fmt"
+ "regexp"
+
+ "github.com/golang/protobuf/proto"
+ "github.com/golang/protobuf/protoc-gen-go/descriptor"
+ "gitlab.com/gitlab-org/gitaly/internal/praefect/pb"
+)
+
+var (
+ requestRegex = regexp.MustCompile(".*Request")
+)
+
+// ensureMsgOpType will ensure that message includes the op_type option.
+// See proto example below:
+//
+// message ExampleRequest {
+// option (op_type).op = ACCESSOR;
+// }
+func ensureMsgOpType(file string, msg *descriptor.DescriptorProto) error {
+ options := msg.GetOptions()
+ //
+ // if options == nil {
+ // log.Printf("%s: Message %s missing options", file, msg.GetName())
+ // return errMissingOpType
+ // }
+
+ if !proto.HasExtension(options, pb.E_OpType) {
+ return fmt.Errorf(
+ "%s: Message %s missing op_type option",
+ file,
+ msg.GetName(),
+ )
+ }
+
+ ext, err := proto.GetExtension(options, pb.E_OpType)
+ if err != nil {
+ return err
+ }
+
+ opMsg, ok := ext.(*pb.OperationMsg)
+ if !ok {
+ return fmt.Errorf("unable to obtain OperationMsg from %#v", ext)
+ }
+
+ // TODO: check if enum is set to UNKNOWN:
+ switch opMsg.GetOp() {
+
+ case pb.OperationMsg_ACCESSOR, pb.OperationMsg_MUTATOR:
+ return nil
+
+ case pb.OperationMsg_UNKNOWN:
+ return fmt.Errorf(
+ "%s: Message %s has op set to UNKNOWN",
+ file,
+ msg.GetName(),
+ )
+ }
+
+ return nil
+}
+
+func LintFile(file *descriptor.FileDescriptorProto) []error {
+ var errs []error
+
+ for _, msg := range file.GetMessageType() {
+ if !requestRegex.MatchString(msg.GetName()) {
+ continue
+ }
+
+ err := ensureMsgOpType(file.GetName(), msg)
+ if err != nil {
+ errs = append(errs, err)
+ }
+
+ }
+
+ return errs
+}
diff --git a/internal/praefect/pb/linter/lint_test.go b/internal/praefect/pb/linter/lint_test.go
new file mode 100644
index 000000000..57079d065
--- /dev/null
+++ b/internal/praefect/pb/linter/lint_test.go
@@ -0,0 +1,67 @@
+package main_test
+
+import (
+ "bytes"
+ "compress/gzip"
+ "errors"
+ "fmt"
+ "io/ioutil"
+ "testing"
+
+ "github.com/golang/protobuf/proto"
+ "github.com/golang/protobuf/protoc-gen-go/descriptor"
+ "github.com/stretchr/testify/require"
+ main "gitlab.com/pokstad1/protoc-gen-gitaly"
+ _ "gitlab.com/pokstad1/protoc-gen-gitaly/testdata"
+)
+
+func TestLintFile(t *testing.T) {
+ for _, tt := range []struct {
+ protoPath string
+ errs []error
+ }{
+ {
+ protoPath: "valid.proto",
+ errs: nil,
+ },
+ {
+ protoPath: "invalid.proto",
+ errs: []error{
+ errors.New("invalid.proto: Message InvalidRequest has op set to UNKNOWN"),
+ },
+ },
+ {
+ protoPath: "incomplete.proto",
+ errs: []error{
+ errors.New("incomplete.proto: Message IncompleteRequest missing op_type option"),
+ },
+ },
+ } {
+ fd, err := extractFile(proto.FileDescriptor(tt.protoPath))
+ require.NoError(t, err)
+
+ errs := main.LintFile(fd)
+ require.Equal(t, tt.errs, errs)
+ }
+}
+
+// extractFile extracts a FileDescriptorProto from a gzip'd buffer.
+func extractFile(gz []byte) (*descriptor.FileDescriptorProto, error) {
+ r, err := gzip.NewReader(bytes.NewReader(gz))
+ if err != nil {
+ return nil, fmt.Errorf("failed to open gzip reader: %v", err)
+ }
+ defer r.Close()
+
+ b, err := ioutil.ReadAll(r)
+ if err != nil {
+ return nil, fmt.Errorf("failed to uncompress descriptor: %v", err)
+ }
+
+ fd := new(descriptor.FileDescriptorProto)
+ if err := proto.Unmarshal(b, fd); err != nil {
+ return nil, fmt.Errorf("malformed FileDescriptorProto: %v", err)
+ }
+
+ return fd, nil
+}
diff --git a/internal/praefect/pb/linter/testdata/incomplete.pb.go b/internal/praefect/pb/linter/testdata/incomplete.pb.go
new file mode 100644
index 000000000..83c6c2c9b
--- /dev/null
+++ b/internal/praefect/pb/linter/testdata/incomplete.pb.go
@@ -0,0 +1,68 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: incomplete.proto
+
+package test
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+// IncompleteRequest is missing the required option, so we expect a failure
+type IncompleteRequest struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *IncompleteRequest) Reset() { *m = IncompleteRequest{} }
+func (m *IncompleteRequest) String() string { return proto.CompactTextString(m) }
+func (*IncompleteRequest) ProtoMessage() {}
+func (*IncompleteRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_117c6bfd926ed1ba, []int{0}
+}
+
+func (m *IncompleteRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_IncompleteRequest.Unmarshal(m, b)
+}
+func (m *IncompleteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_IncompleteRequest.Marshal(b, m, deterministic)
+}
+func (m *IncompleteRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_IncompleteRequest.Merge(m, src)
+}
+func (m *IncompleteRequest) XXX_Size() int {
+ return xxx_messageInfo_IncompleteRequest.Size(m)
+}
+func (m *IncompleteRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_IncompleteRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_IncompleteRequest proto.InternalMessageInfo
+
+func init() {
+ proto.RegisterType((*IncompleteRequest)(nil), "test.IncompleteRequest")
+}
+
+func init() { proto.RegisterFile("incomplete.proto", fileDescriptor_117c6bfd926ed1ba) }
+
+var fileDescriptor_117c6bfd926ed1ba = []byte{
+ // 76 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc8, 0xcc, 0x4b, 0xce,
+ 0xcf, 0x2d, 0xc8, 0x49, 0x2d, 0x49, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x29, 0x49,
+ 0x2d, 0x2e, 0x91, 0xe2, 0xc9, 0x2f, 0x28, 0xa9, 0x2c, 0x80, 0x8a, 0x29, 0x09, 0x73, 0x09, 0x7a,
+ 0xc2, 0xd5, 0x05, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x24, 0xb1, 0x81, 0xe5, 0x8c, 0x01, 0x01,
+ 0x00, 0x00, 0xff, 0xff, 0xa0, 0x36, 0xd7, 0x43, 0x43, 0x00, 0x00, 0x00,
+}
diff --git a/internal/praefect/pb/linter/testdata/incomplete.proto b/internal/praefect/pb/linter/testdata/incomplete.proto
new file mode 100644
index 000000000..7d93ee767
--- /dev/null
+++ b/internal/praefect/pb/linter/testdata/incomplete.proto
@@ -0,0 +1,9 @@
+syntax = "proto3";
+
+package test;
+
+import "optype.proto";
+
+// IncompleteRequest is missing the required option, so we expect a failure
+message IncompleteRequest {
+}
diff --git a/internal/praefect/pb/linter/testdata/invalid.pb.go b/internal/praefect/pb/linter/testdata/invalid.pb.go
new file mode 100644
index 000000000..5a2543e28
--- /dev/null
+++ b/internal/praefect/pb/linter/testdata/invalid.pb.go
@@ -0,0 +1,69 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: invalid.proto
+
+package test
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+// InvalidRequest did not set the operation type to a valid option
+type InvalidRequest struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *InvalidRequest) Reset() { *m = InvalidRequest{} }
+func (m *InvalidRequest) String() string { return proto.CompactTextString(m) }
+func (*InvalidRequest) ProtoMessage() {}
+func (*InvalidRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_bb882c37c371ca1c, []int{0}
+}
+
+func (m *InvalidRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_InvalidRequest.Unmarshal(m, b)
+}
+func (m *InvalidRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_InvalidRequest.Marshal(b, m, deterministic)
+}
+func (m *InvalidRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_InvalidRequest.Merge(m, src)
+}
+func (m *InvalidRequest) XXX_Size() int {
+ return xxx_messageInfo_InvalidRequest.Size(m)
+}
+func (m *InvalidRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_InvalidRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_InvalidRequest proto.InternalMessageInfo
+
+func init() {
+ proto.RegisterType((*InvalidRequest)(nil), "test.InvalidRequest")
+}
+
+func init() { proto.RegisterFile("invalid.proto", fileDescriptor_bb882c37c371ca1c) }
+
+var fileDescriptor_bb882c37c371ca1c = []byte{
+ // 82 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcd, 0xcc, 0x2b, 0x4b,
+ 0xcc, 0xc9, 0x4c, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x29, 0x49, 0x2d, 0x2e, 0x91,
+ 0xe2, 0xc9, 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x85, 0x88, 0x29, 0x49, 0x70, 0xf1, 0x79, 0x42, 0x14,
+ 0x05, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x58, 0xb1, 0x7d, 0x9a, 0xae, 0xc1, 0xc4, 0xc1, 0x90,
+ 0xc4, 0x06, 0x56, 0x60, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x6c, 0xaf, 0x50, 0x45, 0x00,
+ 0x00, 0x00,
+}
diff --git a/internal/praefect/pb/linter/testdata/invalid.proto b/internal/praefect/pb/linter/testdata/invalid.proto
new file mode 100644
index 000000000..bd133c167
--- /dev/null
+++ b/internal/praefect/pb/linter/testdata/invalid.proto
@@ -0,0 +1,10 @@
+syntax = "proto3";
+
+package test;
+
+import "optype.proto";
+
+// InvalidRequest did not set the operation type to a valid option
+message InvalidRequest {
+ option (pb.op_type).op = UNKNOWN;
+}
diff --git a/internal/praefect/pb/linter/testdata/valid.pb.go b/internal/praefect/pb/linter/testdata/valid.pb.go
new file mode 100644
index 000000000..8f09ca689
--- /dev/null
+++ b/internal/praefect/pb/linter/testdata/valid.pb.go
@@ -0,0 +1,70 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: valid.proto
+
+package test
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+// TestRequest has the required option, so we should not expect it to cause
+// a failure
+type TestRequest struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *TestRequest) Reset() { *m = TestRequest{} }
+func (m *TestRequest) String() string { return proto.CompactTextString(m) }
+func (*TestRequest) ProtoMessage() {}
+func (*TestRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_6bda6afcf0898d4a, []int{0}
+}
+
+func (m *TestRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_TestRequest.Unmarshal(m, b)
+}
+func (m *TestRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_TestRequest.Marshal(b, m, deterministic)
+}
+func (m *TestRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_TestRequest.Merge(m, src)
+}
+func (m *TestRequest) XXX_Size() int {
+ return xxx_messageInfo_TestRequest.Size(m)
+}
+func (m *TestRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_TestRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_TestRequest proto.InternalMessageInfo
+
+func init() {
+ proto.RegisterType((*TestRequest)(nil), "test.TestRequest")
+}
+
+func init() { proto.RegisterFile("valid.proto", fileDescriptor_6bda6afcf0898d4a) }
+
+var fileDescriptor_6bda6afcf0898d4a = []byte{
+ // 81 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2e, 0x4b, 0xcc, 0xc9,
+ 0x4c, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x29, 0x49, 0x2d, 0x2e, 0x91, 0xe2, 0xc9,
+ 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x85, 0x88, 0x29, 0x89, 0x72, 0x71, 0x87, 0xa4, 0x16, 0x97, 0x04,
+ 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x58, 0xb1, 0x7d, 0x9a, 0xae, 0xc1, 0xc4, 0xc1, 0x94, 0xc4,
+ 0x06, 0x96, 0x35, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xa3, 0x43, 0xd5, 0xfe, 0x40, 0x00, 0x00,
+ 0x00,
+}
diff --git a/internal/praefect/pb/linter/testdata/valid.proto b/internal/praefect/pb/linter/testdata/valid.proto
new file mode 100644
index 000000000..9521481ce
--- /dev/null
+++ b/internal/praefect/pb/linter/testdata/valid.proto
@@ -0,0 +1,11 @@
+syntax = "proto3";
+
+package test;
+
+import "optype.proto";
+
+// TestRequest has the required option, so we should not expect it to cause
+// a failure
+message TestRequest {
+ option (pb.op_type).op = ACCESSOR;
+}
diff --git a/internal/praefect/pb/optype.pb.go b/internal/praefect/pb/optype.pb.go
new file mode 100644
index 000000000..1946ceb04
--- /dev/null
+++ b/internal/praefect/pb/optype.pb.go
@@ -0,0 +1,124 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: pb/optype.proto
+
+package pb
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+type OperationMsg_Operation int32
+
+const (
+ OperationMsg_UNKNOWN OperationMsg_Operation = 0
+ OperationMsg_MUTATOR OperationMsg_Operation = 1
+ OperationMsg_ACCESSOR OperationMsg_Operation = 2
+)
+
+var OperationMsg_Operation_name = map[int32]string{
+ 0: "UNKNOWN",
+ 1: "MUTATOR",
+ 2: "ACCESSOR",
+}
+
+var OperationMsg_Operation_value = map[string]int32{
+ "UNKNOWN": 0,
+ "MUTATOR": 1,
+ "ACCESSOR": 2,
+}
+
+func (x OperationMsg_Operation) String() string {
+ return proto.EnumName(OperationMsg_Operation_name, int32(x))
+}
+
+func (OperationMsg_Operation) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_4616239e690f8622, []int{0, 0}
+}
+
+type OperationMsg struct {
+ Op OperationMsg_Operation `protobuf:"varint,1,opt,name=op,proto3,enum=pb.OperationMsg_Operation" json:"op,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *OperationMsg) Reset() { *m = OperationMsg{} }
+func (m *OperationMsg) String() string { return proto.CompactTextString(m) }
+func (*OperationMsg) ProtoMessage() {}
+func (*OperationMsg) Descriptor() ([]byte, []int) {
+ return fileDescriptor_4616239e690f8622, []int{0}
+}
+
+func (m *OperationMsg) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_OperationMsg.Unmarshal(m, b)
+}
+func (m *OperationMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_OperationMsg.Marshal(b, m, deterministic)
+}
+func (m *OperationMsg) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_OperationMsg.Merge(m, src)
+}
+func (m *OperationMsg) XXX_Size() int {
+ return xxx_messageInfo_OperationMsg.Size(m)
+}
+func (m *OperationMsg) XXX_DiscardUnknown() {
+ xxx_messageInfo_OperationMsg.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_OperationMsg proto.InternalMessageInfo
+
+func (m *OperationMsg) GetOp() OperationMsg_Operation {
+ if m != nil {
+ return m.Op
+ }
+ return OperationMsg_UNKNOWN
+}
+
+var E_OpType = &proto.ExtensionDesc{
+ ExtendedType: (*descriptor.MessageOptions)(nil),
+ ExtensionType: (*OperationMsg)(nil),
+ Field: 82302,
+ Name: "pb.op_type",
+ Tag: "bytes,82302,opt,name=op_type",
+ Filename: "pb/optype.proto",
+}
+
+func init() {
+ proto.RegisterEnum("pb.OperationMsg_Operation", OperationMsg_Operation_name, OperationMsg_Operation_value)
+ proto.RegisterType((*OperationMsg)(nil), "pb.OperationMsg")
+ proto.RegisterExtension(E_OpType)
+}
+
+func init() { proto.RegisterFile("pb/optype.proto", fileDescriptor_4616239e690f8622) }
+
+var fileDescriptor_4616239e690f8622 = []byte{
+ // 214 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2f, 0x48, 0xd2, 0xcf,
+ 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2a, 0x48, 0x92,
+ 0x52, 0x48, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0xd5, 0x07, 0x8b, 0x24, 0x95, 0xa6, 0xe9, 0xa7, 0xa4,
+ 0x16, 0x27, 0x17, 0x65, 0x16, 0x94, 0xe4, 0x17, 0x41, 0x54, 0x29, 0xe5, 0x73, 0xf1, 0xf8, 0x17,
+ 0xa4, 0x16, 0x25, 0x96, 0x64, 0xe6, 0xe7, 0xf9, 0x16, 0xa7, 0x0b, 0x69, 0x71, 0x31, 0xe5, 0x17,
+ 0x48, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x19, 0x49, 0xe9, 0x15, 0x24, 0xe9, 0x21, 0xcb, 0x22, 0x38,
+ 0x41, 0x4c, 0xf9, 0x05, 0x4a, 0xc6, 0x5c, 0x9c, 0x70, 0x01, 0x21, 0x6e, 0x2e, 0xf6, 0x50, 0x3f,
+ 0x6f, 0x3f, 0xff, 0x70, 0x3f, 0x01, 0x06, 0x10, 0xc7, 0x37, 0x34, 0xc4, 0x31, 0xc4, 0x3f, 0x48,
+ 0x80, 0x51, 0x88, 0x87, 0x8b, 0xc3, 0xd1, 0xd9, 0xd9, 0x35, 0x38, 0xd8, 0x3f, 0x48, 0x80, 0xc9,
+ 0xca, 0x87, 0x8b, 0x3d, 0xbf, 0x20, 0x1e, 0xe4, 0x4e, 0x21, 0x79, 0x3d, 0x88, 0xf3, 0xf4, 0x60,
+ 0xce, 0xd3, 0xf3, 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0xf5, 0x2f, 0x00, 0x19, 0x59, 0x2c, 0xf1,
+ 0xaf, 0x89, 0x55, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x00, 0xdd, 0x21, 0x41, 0x6c, 0xf9, 0x05, 0x21,
+ 0x95, 0x05, 0xa9, 0x49, 0x6c, 0x60, 0xad, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x69, 0xb6,
+ 0xc8, 0x20, 0xfe, 0x00, 0x00, 0x00,
+}
diff --git a/internal/praefect/pb/optype.proto b/internal/praefect/pb/optype.proto
new file mode 100644
index 000000000..f0f261240
--- /dev/null
+++ b/internal/praefect/pb/optype.proto
@@ -0,0 +1,20 @@
+syntax = "proto3";
+
+package pb;
+
+import "google/protobuf/descriptor.proto";
+
+message OperationMsg {
+ enum Operation {
+ UNKNOWN = 0;
+ MUTATOR = 1;
+ ACCESSOR = 2;
+ }
+
+ Operation op = 1;
+}
+
+extend google.protobuf.MessageOptions {
+ // Random high number..
+ OperationMsg op_type = 82302;
+}