diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b3a577e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: ci + +on: + push: + branches: + - main + pull_request: + +shell: bash + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + + - name: run protolint + uses: plexsystems/protolint-action@v0.7.0 + + build: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + + - name: Install Protoc + uses: arduino/setup-protoc@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: '1.21' + - name: Install protoc-gen-go + run: go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + + - name: generate language files + run: make all clean diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f3d1484 --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +# Ignore Protobuf compiler generated files +*.pb.go +*.pb.cc +*.pb.h +*.pb.java +*.pb.py +*.pb2.py + +# Ignore build files +/build/ +*.o +*.so +*.dylib +*.a +*.exe + +# Ignore IDE and editor-specific files +.idea/ +.vscode/ +*.iml +*.swp + +# Ignore OS-specific files +.DS_Store +Thumbs.db diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5aa0949 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +OUT_DIR=build + +# Go-specific settings +GO_OUT=$(OUT_DIR)/go + +.PHONY: all clean go + +all: go + +go: + @echo "Generating Go code..." + mkdir -p $(GO_OUT) + protoc -I=./proto --go_out=$(GO_OUT) ./proto/*.proto + +clean: + @echo "Cleaning up generated files..." + rm -rf $(OUT_DIR) + diff --git a/proto/http.proto b/proto/http.proto new file mode 100644 index 0000000..f2946d4 --- /dev/null +++ b/proto/http.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; + +package tarmac.http; + +import "tarmac.proto"; +option go_package = "github.com/tarmac-project/tarmac/proto"; + +// HTTPClient is a structure used to create HTTP calls to remote systems. +message HTTPClient { + // Method is the HTTP method type for the HTTP request; valid options are + // GET, POST, PUT, PATCH, HEAD, & DELETE. + string method = 1; + // Headers are the HTTP headers to include in the HTTP request. + map headers = 2; + // URL is the HTTP URL to call. + string url = 3; + // Body is the user-supplied HTTP body data. This field should contain the + // request payload data. + bytes body = 4; + // Insecure will disable TLS host verification; this is common with + // self-signed certificates; however, use caution. + bool insecure = 5; +} + +// HTTPClientResponse is a structure supplied as a response message to a remote +// HTTP call callback function. +message HTTPClientResponse { + // Status is the human readable error message or success message for function + // execution. + tarmac.Status status = 1; + // Code is the HTTP Status Code returned from the target server. + int32 code = 2; + // Headers are the HTTP headers returned from the HTTP request. + map headers = 3; + // Body is the server-supplied HTTP payload data. The server-supplied payload + // will be a byte slice. + bytes body = 4; +} + diff --git a/proto/kvstore.proto b/proto/kvstore.proto new file mode 100644 index 0000000..9e76ca2 --- /dev/null +++ b/proto/kvstore.proto @@ -0,0 +1,88 @@ +syntax = "proto3"; + +package tarmac.kvstore; + +import "tarmac.proto"; +option go_package = "github.com/tarmac-project/tarmac/proto"; + +// KVStoreGet is a structure used to create Get request callbacks to the Tarmac +// KVStore interface. +// +// This structure is a general request type used for all KVStore types provided +// by Tarmac. +message KVStoreGet { + // Key is the index key to use when accessing the key:value store. + string key = 1; +} + +// KVStoreGetResponse is a structure supplied as response messages to KVStore +// Get requests. +// +// This response is a general response type used for all KVStore types provided +// by Tarmac. +message KVStoreGetResponse { + // Status is the human readable error message or success message for function + // execution. + tarmac.Status status = 1; + // Data is the response data provided by the key:value store. + // This data is a byte slice to provide a simple field for arbitrary data. + bytes data = 2; +} + +// KVStoreSet is a structure used to create a Set request callback to the +// Tarmac KVStore interface. +// +// This structure is a general request type used for all KVStore types provided +// by Tarmac. +message KVStoreSet { + // Key is the index key used to store the data. + string key = 1; + // Data is the user-supplied key:value data. + // Tarmac expects this field to be a byte slice. + bytes data = 2; +} + +// KVStoreSetResponse is a structure supplied as a response message to the +// KVStore Set callback function. +// +// This response is a general response type used for all KVStore types provided +// by Tarmac. +message KVStoreSetResponse { + // Status is the human readable error message or success message for function + // execution. + tarmac.Status status = 1; +} + +// KVStoreDelete is a structure used to create Delete callback requests to the +// Tarmac KVStore interface. +// +// This structure is a general request type used for all KVStore types provided +// by Tarmac. +message KVStoreDelete { + // Key is the index key used to store the data. + string key = 1; +} + +// KVStoreDeleteResponse is a structure supplied as a response message to the +// KVStore Delete callback function. +// +// This response is a general response type used for all KVStore types provided +// by Tarmac. +message KVStoreDeleteResponse { + // Status is the human readable error message or success message for function + // execution. + tarmac.Status status = 1; +} + +// KVStoreKeysResponse is a structure supplied as a response message to the +// KVStore Keys callback function. + +// This response is a general response type used for all KVStore types provided +// by Tarmac. +message KVStoreKeysResponse { + // Status is the human readable error message or success message for function + // execution. + tarmac.Status status = 1; + // Keys is a list of keys available within the KV Store. + repeated string keys = 2; +} diff --git a/proto/metrics.proto b/proto/metrics.proto new file mode 100644 index 0000000..f22496c --- /dev/null +++ b/proto/metrics.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package tarmac.metrics; + +option go_package = "github.com/tarmac-project/tarmac/proto"; + +// MetricsCounter is a structure used to create Counter metrics callback +// requests to the Tarmac Metrics interface. +message MetricsCounter { + // Name is the name of the metric as exposed via the metrics HTTP end-point. + string name = 1; +} + +// MetricsGauge is a structure used to create Gauge metrics callback requests +// to the Tarmac Metrics interface. +message MetricsGauge { + // Name is the name of the metric as exposed via the metrics HTTP end-point. + string name = 1; + // Action is the action to be performed for the Gauge metric. + // Valid options are inc (Increment) and dec (Decrement). + string action = 2; // inc or dec +} + +// MetricsHistogram is a structure used to create Histogram metrics callback +// requests to the Tarmac Metrics interface. +message MetricsHistogram { + // Name is the name of the metric as exposed via the metrics HTTP end-point. + string name = 1; + // Value is the value to Observe for the Histogram metric. + double value = 2; +} diff --git a/proto/sql.proto b/proto/sql.proto new file mode 100644 index 0000000..abbe40c --- /dev/null +++ b/proto/sql.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +package tarmac.sql; + +import "tarmac.proto"; +option go_package = "github.com/tarmac-project/tarmac/proto"; + +// SQLQuery is a structure used to create SQL queries to a SQL Database. +message SQLQuery { + // Query is the SQL Query to be executed. This field should be a byte slice + // to avoid conflicts with JSON encoding. + bytes query = 1; +} + +// SQLQueryResponse is a structure supplied as a response message to a SQL +// Database Query. +message SQLQueryResponse { + // Status is the human readable error message or success message for function + // execution. + tarmac.Status status = 1; + // Data is a byte slice representing a JSON structure of the returned rows. + // Each row will contain a column name based map to access data. + bytes data = 2; +} + diff --git a/proto/tarmac.proto b/proto/tarmac.proto new file mode 100644 index 0000000..acf66a0 --- /dev/null +++ b/proto/tarmac.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package tarmac; + +option go_package = "github.com/tarmac-project/tarmac/proto"; + +// Status is used to return a status code and message to clients when +// performing host callbacks to Tarmac. +// +// The status code will indicate failure or success. +// +// Status codes are as follows: +// 000 - Success +// 100 - Failure +// +message Status { + // Code is the status code for callback execution. + int32 code = 1; + // Status is the human readable error message or success message for function + // execution. + string status = 2; +}