Skip to content

Commit

Permalink
Merge pull request #85 from tigrisdata/main
Browse files Browse the repository at this point in the history
Alpha release
  • Loading branch information
efirs authored Aug 10, 2022
2 parents bcf939a + 21374eb commit 9fbb207
Show file tree
Hide file tree
Showing 9 changed files with 434 additions and 72 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ all: lint

.PRECIOUS: ${PROTO_DIR}/%_openapi.yaml ${PROTO_DIR}/%.proto

COMPONENTS = api health admin auth observability

# Generate GRPC client/server, openapi spec, http server
${PROTO_DIR}/%_openapi.yaml ${GEN_DIR}/%.pb.go ${GEN_DIR}/%.pb.gw.go: ${PROTO_DIR}/%.proto
protoc -I. --openapi_out=${API_DIR} --openapi_opt=naming=proto,enum_type=string \
Expand All @@ -28,7 +30,10 @@ ${API_DIR}/client/${V}/%/http.go: ${PROTO_DIR}/%_openapi.yaml
-o ${API_DIR}/client/${V}/$(*F)/http.go \
${PROTO_DIR}/$(*F)_openapi.yaml

generate: ${GEN_DIR}/api.pb.go ${GEN_DIR}/api.pb.gw.go ${GEN_DIR}/health.pb.go ${GEN_DIR}/health.pb.gw.go ${GEN_DIR}/admin.pb.go ${GEN_DIR}/admin.pb.gw.go ${PROTO_DIR}/api_openapi.yaml ${PROTO_DIR}/admin_openapi.yaml
generate: \
$(COMPONENTS:%=$(GEN_DIR)/%.pb.go) \
$(COMPONENTS:%=$(GEN_DIR)/%.pb.gw.go) \
$(COMPONENTS:%=$(PROTO_DIR)/%_openapi.yaml)

client: ${API_DIR}/client/${V}/api/http.go

Expand Down
2 changes: 2 additions & 0 deletions scripts/fix_openapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ yq_fix_object SearchRequest facet
yq_fix_object SearchHit data
yq_fix_object CreateOrUpdateCollectionRequest schema
yq_fix_object StreamEvent data
yq_fix_object PublishRequest messages.items
yq_fix_timestamp ResponseMetadata created_at
yq_fix_timestamp ResponseMetadata updated_at

Expand All @@ -144,6 +145,7 @@ done
yq_streaming_response ReadResponse "collections/{collection}/documents/read"
yq_streaming_response SearchResponse "collections/{collection}/documents/search"
yq_streaming_response EventsResponse "collections/{collection}/events"
yq_streaming_response SubscribeResponse "collections/{collection}/subscribe"

yq_error_response

Expand Down
25 changes: 23 additions & 2 deletions scripts/install_build_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,31 @@ go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0 #generate openapi
go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1 #generate go http client
go install github.com/mikefarah/yq/v4@latest # used to fix OpenAPI spec in scripts/fix_openapi.sh

if [[ "$OSTYPE" == "darwin"* ]]; then
ARCH=$(uname -m)
OS=$(uname -s)
PROTO_VERSION=3.15.8
PB_REL="https://github.com/protocolbuffers/protobuf/releases"

if [[ "$OS" == "Darwin" ]]; then
if command -v brew > /dev/null 2>&1; then
brew install protobuf
fi
else
sudo apt-get install -y protobuf-compiler
case "${OS}-${ARCH}" in
"Linux-aarch64")
RELEASE=protoc-$PROTO_VERSION-linux-aarch_64.zip
;;
"Linux-x86_64")
RELEASE=protoc-$PROTO_VERSION-linux-x86_64.zip
;;
*)
echo "Unsupported architecture ${ARCH} or operating system ${OS}"
exit 1
esac

DOWNLOAD_URL=$PB_REL/download/v$PROTO_VERSION/$RELEASE
echo "Fetching release ${DOWNLOAD_URL}"
curl -LO $DOWNLOAD_URL
unzip $RELEASE -d "$HOME/.local"
export PATH="$PATH:$HOME/.local/bin"
fi
45 changes: 31 additions & 14 deletions server/v1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,13 @@ message FacetCount {
// Additional stats for faceted field
message FacetStats {
// Average of all values in a field. Only available for numeric fields
double avg = 1;
optional double avg = 1;
// Maximum of all values in a field. Only available for numeric fields
double max = 2;
optional double max = 2;
// Minimum of all values in a field. Only available for numeric fields
double min = 3;
optional double min = 3;
// Sum of all values in a field. Only available for numeric fields
double sum = 4;
optional double sum = 4;
// Total number of values in a field
int64 count = 5;
}
Expand Down Expand Up @@ -481,6 +481,7 @@ message CreateOrUpdateCollectionRequest {
bytes schema = 3;
bool only_create = 4;
CollectionOptions options = 5;
CollectionType type = 6;
}

message CreateOrUpdateCollectionResponse {
Expand Down Expand Up @@ -611,6 +612,12 @@ message DatabaseMetadata {
}

message CollectionMetadata {
CollectionType type = 1;
}

enum CollectionType {
DOCUMENTS = 0;
MESSAGES = 1;
}

message EventsRequestOptions {
Expand Down Expand Up @@ -647,19 +654,29 @@ message GetInfoResponse {
Error error = 2;
}

message PublishRequestOptions {
}

message PublishRequest {
string db = 1;
string topic = 2;
bytes message = 3;
string collection = 2;
repeated bytes messages = 3;
PublishRequestOptions options = 4;
}

message PublishResponse {
string status = 1;
ResponseMetadata metadata = 1;
string status = 2;
repeated bytes keys = 3;
}

message SubscribeRequestOptions {
}

message SubscribeRequest {
string db = 1;
string topic = 2;
string collection = 2;
SubscribeRequestOptions options = 3;
}

message SubscribeResponse {
Expand Down Expand Up @@ -894,23 +911,23 @@ service Tigris {

rpc Publish(PublishRequest) returns (PublishResponse) {
option (google.api.http) = {
post : "/api/v1/databases/{db}/topic/{topic}/publish"
post : "/api/v1/databases/{db}/collections/{collection}/publish"
body : "*"
};
option(openapi.v3.operation) = {
summary: "Publish a message to a topic"
tags: "Topics"
summary: "Publish a message to a collection"
tags: "Collections"
};
}

rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse) {
option (google.api.http) = {
post : "/api/v1/databases/{db}/topic/{topic}/subscribe"
post : "/api/v1/databases/{db}/collections/{collection}/subscribe"
body : "*"
};
option(openapi.v3.operation) = {
summary: "Subscribe to a topic for a stream of messages"
tags: "Topics"
summary: "Subscribe to a collection for a stream of messages"
tags: "Collections"
};
}
}
Loading

0 comments on commit 9fbb207

Please sign in to comment.