From 8a6c348291464d7a85f854924f68777eec8bfb4b Mon Sep 17 00:00:00 2001 From: Ravi Suhag Date: Thu, 6 Jul 2023 03:34:51 -0500 Subject: [PATCH] fix: test and build fixes (#58) * build: improve makefile commands * build: fix build workflow * build: run test with dynamnic tag * build: run test with dynamnic tag * build: run test with dynamnic tag * wip: disable int test * feat: commit proto code * feat: test with vendor * feat: run without dyanmic * test: chekc integration test * test: chekc integration test * test: skip integration test on main --- .github/workflows/build.yaml | 17 +- .github/workflows/integration-test.yaml | 1 - .github/workflows/package.yaml | 7 +- .gitignore | 3 - Dockerfile | 12 +- Makefile | 129 +++--- buf.gen.yaml | 8 + proto/raccoon.pb.go | 561 ++++++++++++++++++++++++ proto/raccoon_grpc.pb.go | 109 +++++ 9 files changed, 746 insertions(+), 101 deletions(-) create mode 100644 buf.gen.yaml create mode 100644 proto/raccoon.pb.go create mode 100644 proto/raccoon_grpc.pb.go diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9c40b272..5f98b0ce 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,4 +1,4 @@ -name: Raccoon Test & Build +name: Test on: - push @@ -7,32 +7,29 @@ on: jobs: test: runs-on: ubuntu-latest - steps: - name: Setup Go uses: actions/setup-go@v2.1.3 with: - go-version: '1.14' - - name: Install Protoc - uses: arduino/setup-protoc@v1 + go-version: "1.14" - name: Checkout repo uses: actions/checkout@v2 - - name: Setup Project - run: make install-protoc; make setup + with: + fetch-depth: 0 - name: Invoking go test run: make test - name: Invoking go bench test run: make test-bench + build: runs-on: ubuntu-latest - steps: - name: Setup Go uses: actions/setup-go@v2.1.3 with: - go-version: '1.14' + go-version: "1.14" - name: Install Protoc uses: arduino/setup-protoc@v1 - uses: actions/checkout@v2 - name: Build - run: make all + run: make build diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 6f6348c3..ebcede12 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -18,6 +18,5 @@ jobs: run: cp .env.test .env - name: Run Raccoon run: make docker-run - - run: make install-protoc && make generate-proto - name: Invoking go test run: INTEGTEST_BOOTSTRAP_SERVER=localhost:9094 INTEGTEST_HOST=localhost:8080 INTEGTEST_TOPIC_FORMAT="clickstream-%s-log" GRPC_SERVER_ADDR="localhost:8081" go test ./integration -v diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml index bebf4602..1e082f8b 100644 --- a/.github/workflows/package.yaml +++ b/.github/workflows/package.yaml @@ -1,12 +1,11 @@ -name: Release Raccoon +name: Release on: push: - # Sequence of patterns matched against refs/tags tags: - - "v*.*.*" # Push events to matching v*, i.e. v1.0, v20.15.10 + - "v*.*.*" jobs: - push-to-docker-hub: + docker: runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/.gitignore b/.gitignore index 07c0c67c..ca19023d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,8 +13,5 @@ coverage .vscode *.env *.idea/ -clickstream-service raccoon -pkg/proto/*.pb.go -proto/*.pb.go .temp diff --git a/Dockerfile b/Dockerfile index 45364ad4..5d845d44 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,15 +3,15 @@ FROM golang:1.14 WORKDIR /app RUN apt-get update && apt-get install unzip --no-install-recommends --assume-yes RUN PROTOC_ZIP=protoc-3.17.3-linux-x86_64.zip && \ -curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/$PROTOC_ZIP && \ -unzip -o $PROTOC_ZIP -d /usr/local bin/protoc && \ -unzip -o $PROTOC_ZIP -d /usr/local 'include/*' && \ -rm -f $PROTOC_ZIP + curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/$PROTOC_ZIP && \ + unzip -o $PROTOC_ZIP -d /usr/local bin/protoc && \ + unzip -o $PROTOC_ZIP -d /usr/local 'include/*' && \ + rm -f $PROTOC_ZIP COPY . . -RUN make install-protoc && make generate-proto && make update-deps && make compile +RUN make build FROM debian:buster-slim WORKDIR /app -COPY --from=0 /app/out/raccoon ./raccoon +COPY --from=0 /app/raccoon ./raccoon COPY . . CMD ["./raccoon"] diff --git a/Makefile b/Makefile index eb3c0a1a..c32d9c64 100644 --- a/Makefile +++ b/Makefile @@ -1,86 +1,61 @@ -.PHONY: all - -ALL_PACKAGES=$(shell go list ./... | grep -v "vendor") -APP_EXECUTABLE="out/raccoon" -COVER_FILE="/tmp/coverage.out" - -all: install-protoc setup compile - -# Setups -setup: generate-proto copy-config - make update-deps - -install-protoc: - @echo "> installing dependencies" - go get -u github.com/golang/protobuf/proto@v1.4.3 - go get -u github.com/golang/protobuf/protoc-gen-go@v1.4.3 - go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1 - -update-deps: - go mod tidy -v - go mod vendor - -copy-config: - cp .env.sample .env - -PROTO_PACKAGE=/proto -generate-proto: - rm -rf .temp - mkdir -p .temp - curl -o .temp/proton.tar.gz -L http://api.github.com/repos/raystack/proton/tarball/main; tar xvf .temp/proton.tar.gz -C .temp/ --strip-components 1 - protoc --proto_path=.temp/ .temp/raystack/raccoon/v1beta1/raccoon.proto --go_out=./ --go_opt=paths=import --go_opt=Mraystack/raccoon/v1beta1/raccoon.proto=$(PROTO_PACKAGE) - protoc --proto_path=.temp/ .temp/raystack/raccoon/v1beta1/raccoon.proto --go-grpc_opt=paths=import --go-grpc_opt=Mraystack/raccoon/v1beta1/raccoon.proto=$(PROTO_PACKAGE) --go-grpc_out=./ - -# Build Lifecycle -compile: - mkdir -p out/ - go build -o $(APP_EXECUTABLE) - -build: copy-config update-deps compile +NAME="github.com/raystack/raccoon" +COMMIT := $(shell git rev-parse --short HEAD) +TAG := "$(shell git rev-list --tags --max-count=1)" +VERSION := "$(shell git describe --tags ${TAG})-next" +BUILD_DIR=dist +PROTON_COMMIT := "ccbf219312db35a934361ebad895cb40145ca235" + +.PHONY: all build clean test tidy vet proto setup format generate + +all: clean test build format lint + +tidy: + @echo "Tidy up go.mod..." + @go mod tidy -v + +lint: ## Lint checker + @echo "Running lint checks using golangci-lint..." + @golangci-lint run + +clean: tidy ## Clean the build artifacts + @echo "Cleaning up build directories..." + @rm -rf $coverage.out ${BUILD_DIR} + +proto: ## Generate the protobuf files + @echo "Generating protobuf from raystack/proton" + @echo " [info] make sure correct version of dependencies are installed using 'make install'" + @buf generate https://github.com/raystack/proton/archive/${PROTON_COMMIT}.zip#strip_components=1 --template buf.gen.yaml --path raystack/raccoon -v + @cp -R proto/raystack/raccoon/v1beta1/* proto/ && rm -Rf proto/raystack + @echo "Protobuf compilation finished" + +setup: ## Install required dependencies + @echo "> Installing dependencies..." + go mod tidy + go install github.com/bufbuild/buf/cmd/buf@v1.23.0 + +config: ## Generate the sample config file + @echo "Initializing sample server config..." + @cp .env.sample .env + +build: ## Build the raccoon binary + @echo "Building racccoon version ${VERSION}..." + go build + @echo "Build complete" install: - go install $(ALL_PACKAGES) - -start: build - ./$(APP_EXECUTABLE) + @echo "Installing Guardian to ${GOBIN}..." + @go install -clean: ## Clean the builds - rm -rf out/ - -# Utility - -fmt: - go fmt $(ALL_PACKAGES) - -vet: - go vet $(ALL_PACKAGES) - -lint: - @for p in $(ALL_PACKAGES); do \ - echo "==> Linting $$p"; \ - golint $$p | { grep -vwE "exported (var|function|method|type|const) \S+ should have comment" || true; } \ - done - -# Tests - -test: lint - ENVIRONMENT=test go test $(shell go list ./... | grep -v "vendor" | grep -v "integration") -v - @go list ./... | grep -v "vendor" | grep -v "integration" | xargs go test -count 1 -cover -short -race -timeout 1m -coverprofile ${COVER_FILE} - @go tool cover -func ${COVER_FILE} | tail -1 | xargs echo test coverage: +test: ## Run the tests + go test $(shell go list ./... | grep -v "vendor" | grep -v "integration") -v test-bench: # run benchmark tests - @go test $(shell go list ./... | grep -v "vendor") -v -bench ./... -run=^Benchmark - -test_ci: install-protoc setup test + @go test $(shell go list ./... | grep -v "vendor") -v -bench ./... -run=^Benchmark ] -# Docker Run +vendor: ## Update the vendor directory + @echo "Updating vendor directory..." + @go mod vendor docker-run: docker-compose build - docker-compose up -d - -docker-stop: - docker-compose stop - -docker-start: - docker-compose start + docker-compose up -d \ No newline at end of file diff --git a/buf.gen.yaml b/buf.gen.yaml new file mode 100644 index 00000000..48067c57 --- /dev/null +++ b/buf.gen.yaml @@ -0,0 +1,8 @@ +version: v1 +plugins: + - plugin: buf.build/protocolbuffers/go:v1.31.0 + out: proto + opt: paths=source_relative + - plugin: buf.build/grpc/go:v1.3.0 + out: proto + opt: paths=source_relative,require_unimplemented_servers=true diff --git a/proto/raccoon.pb.go b/proto/raccoon.pb.go new file mode 100644 index 00000000..6006152a --- /dev/null +++ b/proto/raccoon.pb.go @@ -0,0 +1,561 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc (unknown) +// source: raystack/raccoon/v1beta1/raccoon.proto + +package raccoonv1 + +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 Status int32 + +const ( + Status_STATUS_UNSPECIFIED Status = 0 + Status_STATUS_SUCCESS Status = 1 + Status_STATUS_ERROR Status = 2 +) + +// Enum value maps for Status. +var ( + Status_name = map[int32]string{ + 0: "STATUS_UNSPECIFIED", + 1: "STATUS_SUCCESS", + 2: "STATUS_ERROR", + } + Status_value = map[string]int32{ + "STATUS_UNSPECIFIED": 0, + "STATUS_SUCCESS": 1, + "STATUS_ERROR": 2, + } +) + +func (x Status) Enum() *Status { + p := new(Status) + *p = x + return p +} + +func (x Status) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Status) Descriptor() protoreflect.EnumDescriptor { + return file_raystack_raccoon_v1beta1_raccoon_proto_enumTypes[0].Descriptor() +} + +func (Status) Type() protoreflect.EnumType { + return &file_raystack_raccoon_v1beta1_raccoon_proto_enumTypes[0] +} + +func (x Status) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Status.Descriptor instead. +func (Status) EnumDescriptor() ([]byte, []int) { + return file_raystack_raccoon_v1beta1_raccoon_proto_rawDescGZIP(), []int{0} +} + +type Code int32 + +const ( + // `CODE_UNSPECIFIED` indicates no appropriate/existing code can describe it. + Code_CODE_UNSPECIFIED Code = 0 + // `OK` indicates the request is processed successfully. + Code_CODE_OK Code = 1 + // `BAD_REQUEST` indicates there is something wrong with the request. + Code_CODE_BAD_REQUEST Code = 2 + // `INTERNAL_ERROR` indicates that Raccoon encountered an unexpected condition that prevented it from fulfilling the request. + Code_CODE_INTERNAL_ERROR Code = 3 + // `MAX_CONNECTION_LIMIT_REACHED` indicates that Raccoon is unable to accepts new connection due to max connection is reached. + // + // To prevent Raccoon from eating up resources, connection limit needs to be set. The limit is configurable on Raccoon by setting `SERVER_WEBSOCKET_MAX_CONN` + Code_CODE_MAX_CONNECTION_LIMIT_REACHED Code = 4 + // `MAX_USER_LIMIT_REACHED` indicates that existing connection with the same ID. + // + // Raccoon ensures unique connection using unique identifier passed from the header + // the first time Websocket connection is established. The header key that + // contains unique identifier is configurable on Raccoon by setting `SERVER_WEBSOCKET_CONN_UNIQ_ID_HEADER` + Code_CODE_MAX_USER_LIMIT_REACHED Code = 5 +) + +// Enum value maps for Code. +var ( + Code_name = map[int32]string{ + 0: "CODE_UNSPECIFIED", + 1: "CODE_OK", + 2: "CODE_BAD_REQUEST", + 3: "CODE_INTERNAL_ERROR", + 4: "CODE_MAX_CONNECTION_LIMIT_REACHED", + 5: "CODE_MAX_USER_LIMIT_REACHED", + } + Code_value = map[string]int32{ + "CODE_UNSPECIFIED": 0, + "CODE_OK": 1, + "CODE_BAD_REQUEST": 2, + "CODE_INTERNAL_ERROR": 3, + "CODE_MAX_CONNECTION_LIMIT_REACHED": 4, + "CODE_MAX_USER_LIMIT_REACHED": 5, + } +) + +func (x Code) Enum() *Code { + p := new(Code) + *p = x + return p +} + +func (x Code) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Code) Descriptor() protoreflect.EnumDescriptor { + return file_raystack_raccoon_v1beta1_raccoon_proto_enumTypes[1].Descriptor() +} + +func (Code) Type() protoreflect.EnumType { + return &file_raystack_raccoon_v1beta1_raccoon_proto_enumTypes[1] +} + +func (x Code) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Code.Descriptor instead. +func (Code) EnumDescriptor() ([]byte, []int) { + return file_raystack_raccoon_v1beta1_raccoon_proto_rawDescGZIP(), []int{1} +} + +// `EventRequest` defines the contract to push events to Raccoon +// +// An `EventRequest` allows you to push more than one events(batch). The events +// are wrapped inside `events` repeated field. All of the fields on `EventRequest` +// are required. +type SendEventRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // `req_guid` is unique identifier of the request the client is making. + // + // Raccoon uses the identifier to send response of the request. The client can handle the + // response accordingly. For example, the client can retry the request in case the response is + // giving `INTERNAL_ERROR` code with "publisher failed" reason. + // + // This identifier is necessary because on event-based protocols like WebSocket the response is + // returned asynchronously. If there is no identifier, no way the client can tell which response + // belongs to which request. + // + // Apart from sending response, `req_guid` is used to log some informations on 'debug' level. You can search the + // debug logs with `ReqGUID` keyword. + ReqGuid string `protobuf:"bytes,1,opt,name=req_guid,json=reqGuid,proto3" json:"req_guid,omitempty"` + // `sent_time` defines the time the request is sent. + // + // `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the + // request is sent until the events are published. + SentTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=sent_time,json=sentTime,proto3" json:"sent_time,omitempty"` + // `events` is where the client put all the events wrapped in `Event`. + // + // As mentioned above, the request allows the client to push more than one event. Normally you want to batch + // the events to optimize the network call. + Events []*Event `protobuf:"bytes,3,rep,name=events,proto3" json:"events,omitempty"` +} + +func (x *SendEventRequest) Reset() { + *x = SendEventRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_raystack_raccoon_v1beta1_raccoon_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SendEventRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendEventRequest) ProtoMessage() {} + +func (x *SendEventRequest) ProtoReflect() protoreflect.Message { + mi := &file_raystack_raccoon_v1beta1_raccoon_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 SendEventRequest.ProtoReflect.Descriptor instead. +func (*SendEventRequest) Descriptor() ([]byte, []int) { + return file_raystack_raccoon_v1beta1_raccoon_proto_rawDescGZIP(), []int{0} +} + +func (x *SendEventRequest) GetReqGuid() string { + if x != nil { + return x.ReqGuid + } + return "" +} + +func (x *SendEventRequest) GetSentTime() *timestamppb.Timestamp { + if x != nil { + return x.SentTime + } + return nil +} + +func (x *SendEventRequest) GetEvents() []*Event { + if x != nil { + return x.Events + } + return nil +} + +type Event struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // `event_bytes` is where you put bytes serialized event. + EventBytes []byte `protobuf:"bytes,1,opt,name=event_bytes,json=eventBytes,proto3" json:"event_bytes,omitempty"` + // `type` denotes an event type that the producer of this proto message may set. + // + // It is currently used by raccoon to distribute events to respective Kafka topics. However the + // users of this proto can use this type to set strings which can be processed in their + // ingestion systems to distribute or perform other functions. + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` +} + +func (x *Event) Reset() { + *x = Event{} + if protoimpl.UnsafeEnabled { + mi := &file_raystack_raccoon_v1beta1_raccoon_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Event) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Event) ProtoMessage() {} + +func (x *Event) ProtoReflect() protoreflect.Message { + mi := &file_raystack_raccoon_v1beta1_raccoon_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 Event.ProtoReflect.Descriptor instead. +func (*Event) Descriptor() ([]byte, []int) { + return file_raystack_raccoon_v1beta1_raccoon_proto_rawDescGZIP(), []int{1} +} + +func (x *Event) GetEventBytes() []byte { + if x != nil { + return x.EventBytes + } + return nil +} + +func (x *Event) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +type SendEventResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // `status` denotes status of the request. + // + // Only 3 values are valid. `SUCCESS` means the the request is processed + // successfully. `ERROR` means the request failed to be processed. `UNKNOWN_STATUS` + // means Raccoon unable to determine whether the request is success or not. + Status Status `protobuf:"varint,1,opt,name=status,proto3,enum=raystack.raccoon.v1beta1.Status" json:"status,omitempty"` + // `code` gives more detail of what happened to the request. + // + // Details of available `code` can be seen below. + Code Code `protobuf:"varint,2,opt,name=code,proto3,enum=raystack.raccoon.v1beta1.Code" json:"code,omitempty"` + // `sent_time` is UNIX timestamp populated by Raccoon by the time the response is sent. + SentTime int64 `protobuf:"varint,3,opt,name=sent_time,json=sentTime,proto3" json:"sent_time,omitempty"` + // `reason` is additional-human readable information to provide more context to `status` and `code`. + // + // There is no predefined structure for this. The value is arbitrary. + Reason string `protobuf:"bytes,4,opt,name=reason,proto3" json:"reason,omitempty"` + // `data` is arbitrary extra metadata. + // + // Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part + // of `data`. The client may fetch req_guid as key to get the `req_guid` value. + Data map[string]string `protobuf:"bytes,5,rep,name=data,proto3" json:"data,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *SendEventResponse) Reset() { + *x = SendEventResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_raystack_raccoon_v1beta1_raccoon_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SendEventResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendEventResponse) ProtoMessage() {} + +func (x *SendEventResponse) ProtoReflect() protoreflect.Message { + mi := &file_raystack_raccoon_v1beta1_raccoon_proto_msgTypes[2] + 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 SendEventResponse.ProtoReflect.Descriptor instead. +func (*SendEventResponse) Descriptor() ([]byte, []int) { + return file_raystack_raccoon_v1beta1_raccoon_proto_rawDescGZIP(), []int{2} +} + +func (x *SendEventResponse) GetStatus() Status { + if x != nil { + return x.Status + } + return Status_STATUS_UNSPECIFIED +} + +func (x *SendEventResponse) GetCode() Code { + if x != nil { + return x.Code + } + return Code_CODE_UNSPECIFIED +} + +func (x *SendEventResponse) GetSentTime() int64 { + if x != nil { + return x.SentTime + } + return 0 +} + +func (x *SendEventResponse) GetReason() string { + if x != nil { + return x.Reason + } + return "" +} + +func (x *SendEventResponse) GetData() map[string]string { + if x != nil { + return x.Data + } + return nil +} + +var File_raystack_raccoon_v1beta1_raccoon_proto protoreflect.FileDescriptor + +var file_raystack_raccoon_v1beta1_raccoon_proto_rawDesc = []byte{ + 0x0a, 0x26, 0x72, 0x61, 0x79, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2f, 0x72, 0x61, 0x63, 0x63, 0x6f, + 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x72, 0x61, 0x63, 0x63, 0x6f, + 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x72, 0x61, 0x79, 0x73, 0x74, 0x61, + 0x63, 0x6b, 0x2e, 0x72, 0x61, 0x63, 0x63, 0x6f, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 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, 0x9f, 0x01, 0x0a, 0x10, 0x53, 0x65, 0x6e, 0x64, 0x45, 0x76, 0x65, 0x6e, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x5f, + 0x67, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x71, 0x47, + 0x75, 0x69, 0x64, 0x12, 0x37, 0x0a, 0x09, 0x73, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0x02, 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, 0x08, 0x73, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x37, 0x0a, 0x06, + 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x72, + 0x61, 0x79, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x72, 0x61, 0x63, 0x63, 0x6f, 0x6f, 0x6e, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, + 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x3c, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x1f, + 0x0a, 0x0b, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x22, 0xba, 0x02, 0x0a, 0x11, 0x53, 0x65, 0x6e, 0x64, 0x45, 0x76, 0x65, 0x6e, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x38, 0x0a, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x72, 0x61, 0x79, 0x73, + 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x72, 0x61, 0x63, 0x63, 0x6f, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x32, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x1e, 0x2e, 0x72, 0x61, 0x79, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x72, 0x61, 0x63, + 0x63, 0x6f, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x64, + 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x6e, 0x74, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65, 0x6e, 0x74, + 0x54, 0x69, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x49, 0x0a, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x72, 0x61, 0x79, + 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x72, 0x61, 0x63, 0x63, 0x6f, 0x6f, 0x6e, 0x2e, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x37, 0x0a, 0x09, 0x44, 0x61, 0x74, 0x61, 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, + 0x2a, 0x46, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, + 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, + 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x53, 0x55, 0x43, + 0x43, 0x45, 0x53, 0x53, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, + 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x02, 0x2a, 0xa0, 0x01, 0x0a, 0x04, 0x43, 0x6f, 0x64, + 0x65, 0x12, 0x14, 0x0a, 0x10, 0x43, 0x4f, 0x44, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, + 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x4f, 0x44, 0x45, 0x5f, + 0x4f, 0x4b, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x43, 0x4f, 0x44, 0x45, 0x5f, 0x42, 0x41, 0x44, + 0x5f, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x10, 0x02, 0x12, 0x17, 0x0a, 0x13, 0x43, 0x4f, + 0x44, 0x45, 0x5f, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x5f, 0x45, 0x52, 0x52, 0x4f, + 0x52, 0x10, 0x03, 0x12, 0x25, 0x0a, 0x21, 0x43, 0x4f, 0x44, 0x45, 0x5f, 0x4d, 0x41, 0x58, 0x5f, + 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4c, 0x49, 0x4d, 0x49, 0x54, + 0x5f, 0x52, 0x45, 0x41, 0x43, 0x48, 0x45, 0x44, 0x10, 0x04, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, + 0x44, 0x45, 0x5f, 0x4d, 0x41, 0x58, 0x5f, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x4c, 0x49, 0x4d, 0x49, + 0x54, 0x5f, 0x52, 0x45, 0x41, 0x43, 0x48, 0x45, 0x44, 0x10, 0x05, 0x32, 0x74, 0x0a, 0x0c, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x64, 0x0a, 0x09, 0x53, + 0x65, 0x6e, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x2a, 0x2e, 0x72, 0x61, 0x79, 0x73, 0x74, + 0x61, 0x63, 0x6b, 0x2e, 0x72, 0x61, 0x63, 0x63, 0x6f, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x72, 0x61, 0x79, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, + 0x72, 0x61, 0x63, 0x63, 0x6f, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, + 0x53, 0x65, 0x6e, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x42, 0x5b, 0x0a, 0x1a, 0x69, 0x6f, 0x2e, 0x72, 0x61, 0x79, 0x73, 0x74, 0x61, 0x63, 0x6b, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x6e, 0x2e, 0x72, 0x61, 0x63, 0x63, 0x6f, 0x6f, 0x6e, 0x42, + 0x0a, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2f, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x61, 0x79, 0x73, 0x74, 0x61, + 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x6e, 0x2f, 0x72, 0x61, 0x63, 0x63, 0x6f, 0x6f, + 0x6e, 0x2f, 0x76, 0x31, 0x3b, 0x72, 0x61, 0x63, 0x63, 0x6f, 0x6f, 0x6e, 0x76, 0x31, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_raystack_raccoon_v1beta1_raccoon_proto_rawDescOnce sync.Once + file_raystack_raccoon_v1beta1_raccoon_proto_rawDescData = file_raystack_raccoon_v1beta1_raccoon_proto_rawDesc +) + +func file_raystack_raccoon_v1beta1_raccoon_proto_rawDescGZIP() []byte { + file_raystack_raccoon_v1beta1_raccoon_proto_rawDescOnce.Do(func() { + file_raystack_raccoon_v1beta1_raccoon_proto_rawDescData = protoimpl.X.CompressGZIP(file_raystack_raccoon_v1beta1_raccoon_proto_rawDescData) + }) + return file_raystack_raccoon_v1beta1_raccoon_proto_rawDescData +} + +var file_raystack_raccoon_v1beta1_raccoon_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_raystack_raccoon_v1beta1_raccoon_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_raystack_raccoon_v1beta1_raccoon_proto_goTypes = []interface{}{ + (Status)(0), // 0: raystack.raccoon.v1beta1.Status + (Code)(0), // 1: raystack.raccoon.v1beta1.Code + (*SendEventRequest)(nil), // 2: raystack.raccoon.v1beta1.SendEventRequest + (*Event)(nil), // 3: raystack.raccoon.v1beta1.Event + (*SendEventResponse)(nil), // 4: raystack.raccoon.v1beta1.SendEventResponse + nil, // 5: raystack.raccoon.v1beta1.SendEventResponse.DataEntry + (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp +} +var file_raystack_raccoon_v1beta1_raccoon_proto_depIdxs = []int32{ + 6, // 0: raystack.raccoon.v1beta1.SendEventRequest.sent_time:type_name -> google.protobuf.Timestamp + 3, // 1: raystack.raccoon.v1beta1.SendEventRequest.events:type_name -> raystack.raccoon.v1beta1.Event + 0, // 2: raystack.raccoon.v1beta1.SendEventResponse.status:type_name -> raystack.raccoon.v1beta1.Status + 1, // 3: raystack.raccoon.v1beta1.SendEventResponse.code:type_name -> raystack.raccoon.v1beta1.Code + 5, // 4: raystack.raccoon.v1beta1.SendEventResponse.data:type_name -> raystack.raccoon.v1beta1.SendEventResponse.DataEntry + 2, // 5: raystack.raccoon.v1beta1.EventService.SendEvent:input_type -> raystack.raccoon.v1beta1.SendEventRequest + 4, // 6: raystack.raccoon.v1beta1.EventService.SendEvent:output_type -> raystack.raccoon.v1beta1.SendEventResponse + 6, // [6:7] is the sub-list for method output_type + 5, // [5:6] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_raystack_raccoon_v1beta1_raccoon_proto_init() } +func file_raystack_raccoon_v1beta1_raccoon_proto_init() { + if File_raystack_raccoon_v1beta1_raccoon_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_raystack_raccoon_v1beta1_raccoon_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendEventRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_raystack_raccoon_v1beta1_raccoon_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Event); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_raystack_raccoon_v1beta1_raccoon_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendEventResponse); 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_raystack_raccoon_v1beta1_raccoon_proto_rawDesc, + NumEnums: 2, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_raystack_raccoon_v1beta1_raccoon_proto_goTypes, + DependencyIndexes: file_raystack_raccoon_v1beta1_raccoon_proto_depIdxs, + EnumInfos: file_raystack_raccoon_v1beta1_raccoon_proto_enumTypes, + MessageInfos: file_raystack_raccoon_v1beta1_raccoon_proto_msgTypes, + }.Build() + File_raystack_raccoon_v1beta1_raccoon_proto = out.File + file_raystack_raccoon_v1beta1_raccoon_proto_rawDesc = nil + file_raystack_raccoon_v1beta1_raccoon_proto_goTypes = nil + file_raystack_raccoon_v1beta1_raccoon_proto_depIdxs = nil +} diff --git a/proto/raccoon_grpc.pb.go b/proto/raccoon_grpc.pb.go new file mode 100644 index 00000000..171753fa --- /dev/null +++ b/proto/raccoon_grpc.pb.go @@ -0,0 +1,109 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: raystack/raccoon/v1beta1/raccoon.proto + +package raccoonv1 + +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 ( + EventService_SendEvent_FullMethodName = "/raystack.raccoon.v1beta1.EventService/SendEvent" +) + +// EventServiceClient is the client API for EventService 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 EventServiceClient interface { + SendEvent(ctx context.Context, in *SendEventRequest, opts ...grpc.CallOption) (*SendEventResponse, error) +} + +type eventServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewEventServiceClient(cc grpc.ClientConnInterface) EventServiceClient { + return &eventServiceClient{cc} +} + +func (c *eventServiceClient) SendEvent(ctx context.Context, in *SendEventRequest, opts ...grpc.CallOption) (*SendEventResponse, error) { + out := new(SendEventResponse) + err := c.cc.Invoke(ctx, EventService_SendEvent_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// EventServiceServer is the server API for EventService service. +// All implementations must embed UnimplementedEventServiceServer +// for forward compatibility +type EventServiceServer interface { + SendEvent(context.Context, *SendEventRequest) (*SendEventResponse, error) + mustEmbedUnimplementedEventServiceServer() +} + +// UnimplementedEventServiceServer must be embedded to have forward compatible implementations. +type UnimplementedEventServiceServer struct { +} + +func (UnimplementedEventServiceServer) SendEvent(context.Context, *SendEventRequest) (*SendEventResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendEvent not implemented") +} +func (UnimplementedEventServiceServer) mustEmbedUnimplementedEventServiceServer() {} + +// UnsafeEventServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to EventServiceServer will +// result in compilation errors. +type UnsafeEventServiceServer interface { + mustEmbedUnimplementedEventServiceServer() +} + +func RegisterEventServiceServer(s grpc.ServiceRegistrar, srv EventServiceServer) { + s.RegisterService(&EventService_ServiceDesc, srv) +} + +func _EventService_SendEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SendEventRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EventServiceServer).SendEvent(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: EventService_SendEvent_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EventServiceServer).SendEvent(ctx, req.(*SendEventRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// EventService_ServiceDesc is the grpc.ServiceDesc for EventService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var EventService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "raystack.raccoon.v1beta1.EventService", + HandlerType: (*EventServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SendEvent", + Handler: _EventService_SendEvent_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "raystack/raccoon/v1beta1/raccoon.proto", +}