-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ns1/bb-payload-v6
Implemented BulkBeacon Protobuf Definitions version 2
- Loading branch information
Showing
10 changed files
with
591 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,45 @@ | ||
BUIlD_BASE_DIR := build | ||
GEN_BASE_DIR := gen | ||
# Copyright 2021 NSONE, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http:#www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
BUILD_BASE_DIR := build | ||
PROTO_BASE_DIR := proto | ||
|
||
all: examples | ||
PB_DIR := proto/bulkbeacon | ||
PB_OUT := pkg/bulkbeacon | ||
GRPC_OUT := pkg/bulkbeacon | ||
PKG_PREFIX := github.com/ns1/pulsar-rum | ||
BUILD := ./build.sh | ||
|
||
all: bulkbeacon_v1 bulkbeacon_v2 | ||
|
||
V1_GO_FILES := $(PB_OUT)/v1/bulkbeacon.pb.go $(PB_OUT)/v1/bulkbeacon_grpc.pb.go | ||
.PHONY: bulkbeacon_v1 | ||
bulkbeacon_v1: $(V1_GO_FILES) | ||
$(V1_GO_FILES): $(PB_DIR)/v1/bulkbeacon.proto | ||
$(BUILD) v1 | ||
mkdir -p $(BUILD_BASE_DIR) | ||
go build -o $(BUILD_BASE_DIR)/grpc_example_client_v1 cmd/example_client_v1/main.go | ||
|
||
.PHONY: examples | ||
examples: | ||
mkdir -p $(GEN_BASE_DIR)/bulkbeacon/v1 $(BUIlD_BASE_DIR) | ||
protoc -I=$(PROTO_BASE_DIR) $(PROTO_BASE_DIR)/bulkbeacon/v1/bulkbeacon.proto --go_out=plugins=grpc:$(GEN_BASE_DIR) | ||
go build -o $(BUIlD_BASE_DIR)/grpc_example_client cmd/example_client/grpc_example_client.go | ||
V2_GO_FILES := $(PB_OUT)/v2/bulkbeacon.pb.go $(PB_OUT)/v2/bulkbeacon_grpc.pb.go | ||
.PHONY: bulkbeacon_v2 | ||
bulkbeacon_v2: $(V2_GO_FILES) | ||
$(V2_GO_FILES): $(PB_DIR)/v2/bulkbeacon.proto | ||
$(BUILD) v2 | ||
mkdir -p $(BUILD_BASE_DIR) | ||
go build -o $(BUILD_BASE_DIR)/grpc_example_client_v2 cmd/example_client_v2/main.go | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf $(GEN_BASE_DIR) $(BUIlD_BASE_DIR) | ||
rm -rf $(BUILD_BASE_DIR) $(PB_OUT)/v2 $(PB_OUT)/v1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
# Copyright 2021 NSONE, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http:#www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Utility for generating protobuf and gRPC artifacts for the Bulk Beacon service. | ||
|
||
valid_versions="v1 v2" | ||
PB_DIR="proto/bulkbeacon" | ||
PB_OUT="pkg/bulkbeacon" | ||
PKG_PREFIX="github.com/ns1/pulsar-rum" | ||
|
||
function validate_version() { | ||
for i in $valid_versions; do | ||
if [[ $i == $1 ]]; then | ||
echo "Bulk Beacon: ${i} is a valid version." | ||
return | ||
fi | ||
done | ||
echo "Error: '$1' is not a valid Bulk Beacon version." | ||
exit 1 | ||
} | ||
|
||
function build() { | ||
v="${1}" | ||
proto_file="${PB_DIR}/${v}/bulkbeacon.proto" | ||
proto_pkg="${PB_OUT}/${v}" | ||
opt_m="M${proto_file}=${PKG_PREFIX}/${PB_OUT}/${v}" | ||
echo "Bulk Beacon: Building ${proto_file}" | ||
mkdir -p "${proto_pkg}" | ||
protoc --go_out=. --go_opt="${opt_m}" --go_opt="module=${PKG_PREFIX}" \ | ||
--go-grpc_out=. --go-grpc_opt="${opt_m}" --go-grpc_opt="module=${PKG_PREFIX}" "${proto_file}" | ||
} | ||
|
||
function usage() { | ||
echo -n "Utility for generating protobuf and gRPC artifacts for the Pulsar Bulk " | ||
echo "Beacon Service." | ||
echo "(c) NS1 Inc." | ||
echo "Usage:" | ||
echo "$0 <v1|v2>" | ||
} | ||
|
||
if [[ $# != 1 ]]; then | ||
usage | ||
exit 1 | ||
elif [[ $1 == "-h" || $1 == "--help" ]]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
validate_version "${1}" | ||
build "${1}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.