Skip to content

Commit

Permalink
fix: move buf.yaml into the module to fix usage package import error (#…
Browse files Browse the repository at this point in the history
…75)

Because

- usage package can't correctly import mgmt package. See [here](https://github.com/instill-ai/protogen-go/blob/1030118a20444e8501a88889b609aab99a351a86/usage/v1alpha/usage.pb.go#L10).

This commit

- put `buf.yaml` in the module folder (See [buf project directory example](https://docs.buf.build/tour/generate-code#generate-c-and-java-stubs))
- add `healthcheck` package and import it to all backends
  • Loading branch information
xiaofei-du authored May 30, 2022
1 parent 62cf175 commit 3b33ff4
Show file tree
Hide file tree
Showing 24 changed files with 504 additions and 426 deletions.
3 changes: 3 additions & 0 deletions buf.work.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v1
directories:
- instill
4 changes: 2 additions & 2 deletions buf.lock → instill/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 2ecc14c6771e48bd86ced753e97424ff
commit: 346b021f31c34ab9a853cb1f5303b0df
- remote: buf.build
owner: grpc-ecosystem
repository: grpc-gateway
commit: febd9e8be39b4f4b878b9c64bcc203fd
commit: 00116f302b12478b85deb33b734e026c
File renamed without changes.
2 changes: 1 addition & 1 deletion instill/connector/v1alpha/auth.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package instill.connector.v1alpha;
package connector.v1alpha;

// Protobuf standard
import "google/protobuf/struct.proto";
Expand Down
4 changes: 2 additions & 2 deletions instill/connector/v1alpha/connector.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package instill.connector.v1alpha;
package connector.v1alpha;

// Protocol Buffers Well-Known Types
import "google/protobuf/timestamp.proto";
Expand All @@ -11,7 +11,7 @@ import "protoc-gen-openapiv2/options/annotations.proto";
import "google/api/resource.proto";
import "google/api/field_behavior.proto";

import "instill/connector/v1alpha/connector_definition.proto";
import "connector/v1alpha/connector_definition.proto";

// Connector represents a connector data model
message Connector {
Expand Down
4 changes: 2 additions & 2 deletions instill/connector/v1alpha/connector_definition.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package instill.connector.v1alpha;
package connector.v1alpha;

// Protocol Buffers Well-Known Types
import "google/protobuf/struct.proto";
Expand All @@ -14,7 +14,7 @@ import "google/api/field_behavior.proto";
// Google type
import "google/type/date.proto";

import "instill/connector/v1alpha/spec.proto";
import "connector/v1alpha/spec.proto";

// View enumerates the definition views
enum View {
Expand Down
43 changes: 25 additions & 18 deletions instill/connector/v1alpha/connector_service.proto
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
syntax = "proto3";

package instill.connector.v1alpha;
package connector.v1alpha;

// Google API
import "google/api/annotations.proto";
import "google/api/client.proto";

import "instill/connector/v1alpha/healthcheck.proto";
import "instill/connector/v1alpha/connector_definition.proto";
import "instill/connector/v1alpha/connector.proto";
import "connector/v1alpha/healthcheck.proto";
import "connector/v1alpha/connector_definition.proto";
import "connector/v1alpha/connector.proto";

///////////////////////////////////////////////////////////////////////////////
// Connector service responds to incoming connector requests.
Expand Down Expand Up @@ -150,8 +150,9 @@ service ConnectorService {

// Connect a source connector.
// The "state" of the connector after connecting is "CONNECTED".
// ConnectSourceConnector can be called on SourceConnector in the state `DISCONNECTED`;
// SourceConnector in a different state (including `CONNECTED`) returns an error.
// ConnectSourceConnector can be called on SourceConnector in the state
// `DISCONNECTED`; SourceConnector in a different state (including
// `CONNECTED`) returns an error.
rpc ConnectSourceConnector(ConnectSourceConnectorRequest)
returns (ConnectSourceConnectorResponse) {
option (google.api.http) = {
Expand All @@ -163,8 +164,9 @@ service ConnectorService {

// Disconnect a source connector.
// The "state" of the connector after disconnecting is "DISCONNECTED".
// DisconnectSourceConnector can be called on SourceConnector in the state `CONNECTED`;
// SourceConnector in a different state (including `DISCONNECTED`) returns an error.
// DisconnectSourceConnector can be called on SourceConnector in the state
// `CONNECTED`; SourceConnector in a different state (including
// `DISCONNECTED`) returns an error.
rpc DisconnectSourceConnector(DisconnectSourceConnectorRequest)
returns (DisconnectSourceConnectorResponse) {
option (google.api.http) = {
Expand All @@ -174,9 +176,10 @@ service ConnectorService {
option (google.api.method_signature) = "name";
}

// RenameDestinationConnector method receives a RenameSourceConnectorRequest message and returns
// a RenameSourceConnectorResponse message.
rpc RenameSourceConnector(RenameSourceConnectorRequest) returns (RenameSourceConnectorResponse) {
// RenameDestinationConnector method receives a RenameSourceConnectorRequest
// message and returns a RenameSourceConnectorResponse message.
rpc RenameSourceConnector(RenameSourceConnectorRequest)
returns (RenameSourceConnectorResponse) {
option (google.api.http) = {
post : "/v1alpha/{name=source-connectors/*}:rename"
body : "*"
Expand Down Expand Up @@ -253,8 +256,9 @@ service ConnectorService {

// Connect a destination connector.
// The "state" of the connector after connecting is "CONNECTED".
// ConnectDestinationConnector can be called on DestinationConnector in the state `DISCONNECTED`;
// DestinationConnector in a different state (including `CONNECTED`) returns an error.
// ConnectDestinationConnector can be called on DestinationConnector in the
// state `DISCONNECTED`; DestinationConnector in a different state (including
// `CONNECTED`) returns an error.
rpc ConnectDestinationConnector(ConnectDestinationConnectorRequest)
returns (ConnectDestinationConnectorResponse) {
option (google.api.http) = {
Expand All @@ -266,8 +270,9 @@ service ConnectorService {

// Disconnect a destination connector.
// The "state" of the connector after disconnecting is "DISCONNECTED".
// DisconnectDestinationConnector can be called on DestinationConnector in the state `CONNECTED`;
// DestinationConnector in a different state (including `DISCONNECTED`) returns an error.
// DisconnectDestinationConnector can be called on DestinationConnector in the
// state `CONNECTED`; DestinationConnector in a different state (including
// `DISCONNECTED`) returns an error.
rpc DisconnectDestinationConnector(DisconnectDestinationConnectorRequest)
returns (DisconnectDestinationConnectorResponse) {
option (google.api.http) = {
Expand All @@ -277,9 +282,11 @@ service ConnectorService {
option (google.api.method_signature) = "name";
}

// RenameDestinationConnector method receives a RenameDestinationConnectorRequest message and returns
// a RenameDestinationConnectorResponse message.
rpc RenameDestinationConnector(RenameDestinationConnectorRequest) returns (RenameDestinationConnectorResponse) {
// RenameDestinationConnector method receives a
// RenameDestinationConnectorRequest message and returns a
// RenameDestinationConnectorResponse message.
rpc RenameDestinationConnector(RenameDestinationConnectorRequest)
returns (RenameDestinationConnectorResponse) {
option (google.api.http) = {
post : "/v1alpha/{name=destination-connectors/*}:rename"
body : "*"
Expand Down
32 changes: 6 additions & 26 deletions instill/connector/v1alpha/healthcheck.proto
Original file line number Diff line number Diff line change
@@ -1,54 +1,34 @@
syntax = "proto3";

package instill.connector.v1alpha;
package connector.v1alpha;

// Google API
import "google/api/field_behavior.proto";

// HealthCheckRequest represents a request to health check a service
message HealthCheckRequest {
// Service name to check for its readiness status
optional string service = 1 [ (google.api.field_behavior) = OPTIONAL ];
}

// HealthCheckResponse represents a response for a service heath status
message HealthCheckResponse {
// ServingStatus enumerates the status of a queried service
enum ServingStatus {
// Serving status: UNSPECIFIED
SERVING_STATUS_UNSPECIFIED = 0;
// Serving status: SERVING
SERVING_STATUS_SERVING = 1;
// Serving status: NOT SERVING
SERVING_STATUS_NOT_SERVING = 2;
}

// Status is the instance of the enum type ServingStatus
ServingStatus status = 1;
}
import "healthcheck/v1alpha/healthcheck.proto";

// LivenessRequest represents a request to check a service liveness status
message LivenessRequest {
// HealthCheckRequest message
optional HealthCheckRequest health_check_request = 1
optional healthcheck.v1alpha.HealthCheckRequest health_check_request = 1
[ (google.api.field_behavior) = OPTIONAL ];
}

// LivenessResponse represents a response for a service liveness status
message LivenessResponse {
// HealthCheckResponse message
HealthCheckResponse health_check_response = 1;
healthcheck.v1alpha.HealthCheckResponse health_check_response = 1;
}

// ReadinessRequest represents a request to check a service readiness status
message ReadinessRequest {
// HealthCheckRequest message
optional HealthCheckRequest health_check_request = 1
optional healthcheck.v1alpha.HealthCheckRequest health_check_request = 1
[ (google.api.field_behavior) = OPTIONAL ];
}

// ReadinessResponse represents a response for a service readiness status
message ReadinessResponse {
// HealthCheckResponse message
HealthCheckResponse health_check_response = 1;
healthcheck.v1alpha.HealthCheckResponse health_check_response = 1;
}
4 changes: 2 additions & 2 deletions instill/connector/v1alpha/spec.proto
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
syntax = "proto3";

package instill.connector.v1alpha;
package connector.v1alpha;

// Protocol Buffers Well-Known Types
import "google/protobuf/struct.proto";

// Google API
import "google/api/field_behavior.proto";

import "instill/connector/v1alpha/auth.proto";
import "connector/v1alpha/auth.proto";

////////////////////////////////////
// Spec represents a spec data model
Expand Down
54 changes: 54 additions & 0 deletions instill/healthcheck/v1alpha/healthcheck.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
syntax = "proto3";

package healthcheck.v1alpha;

// Google API
import "google/api/field_behavior.proto";

// HealthCheckRequest represents a request to health check a service
message HealthCheckRequest {
// Service name to check for its readiness status
optional string service = 1 [ (google.api.field_behavior) = OPTIONAL ];
}

// HealthCheckResponse represents a response for a service heath status
message HealthCheckResponse {
// ServingStatus enumerates the status of a queried service
enum ServingStatus {
// Serving status: UNSPECIFIED
SERVING_STATUS_UNSPECIFIED = 0;
// Serving status: SERVING
SERVING_STATUS_SERVING = 1;
// Serving status: NOT SERVING
SERVING_STATUS_NOT_SERVING = 2;
}

// Status is the instance of the enum type ServingStatus
ServingStatus status = 1;
}

// LivenessRequest represents a request to check a service liveness status
message LivenessRequest {
// HealthCheckRequest message
optional HealthCheckRequest health_check_request = 1
[ (google.api.field_behavior) = OPTIONAL ];
}

// LivenessResponse represents a response for a service liveness status
message LivenessResponse {
// HealthCheckResponse message
HealthCheckResponse health_check_response = 1;
}

// ReadinessRequest represents a request to check a service readiness status
message ReadinessRequest {
// HealthCheckRequest message
optional HealthCheckRequest health_check_request = 1
[ (google.api.field_behavior) = OPTIONAL ];
}

// ReadinessResponse represents a response for a service readiness status
message ReadinessResponse {
// HealthCheckResponse message
HealthCheckResponse health_check_response = 1;
}
34 changes: 34 additions & 0 deletions instill/mgmt/v1alpha/healthcheck.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
syntax = "proto3";

package mgmt.v1alpha;

// Google API
import "google/api/field_behavior.proto";

import "healthcheck/v1alpha/healthcheck.proto";

// LivenessRequest represents a request to check a service liveness status
message LivenessRequest {
// HealthCheckRequest message
optional healthcheck.v1alpha.HealthCheckRequest health_check_request = 1
[ (google.api.field_behavior) = OPTIONAL ];
}

// LivenessResponse represents a response for a service liveness status
message LivenessResponse {
// HealthCheckResponse message
healthcheck.v1alpha.HealthCheckResponse health_check_response = 1;
}

// ReadinessRequest represents a request to check a service readiness status
message ReadinessRequest {
// HealthCheckRequest message
optional healthcheck.v1alpha.HealthCheckRequest health_check_request = 1
[ (google.api.field_behavior) = OPTIONAL ];
}

// ReadinessResponse represents a response for a service readiness status
message ReadinessResponse {
// HealthCheckResponse message
healthcheck.v1alpha.HealthCheckResponse health_check_response = 1;
}
50 changes: 1 addition & 49 deletions instill/mgmt/v1alpha/mgmt.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package instill.mgmt.v1alpha;
package mgmt.v1alpha;

// Protobuf standard
import "google/protobuf/field_mask.proto";
Expand All @@ -11,54 +11,6 @@ import "protoc-gen-openapiv2/options/annotations.proto";
import "google/api/resource.proto";
import "google/api/field_behavior.proto";

// HealthCheckRequest represents a request to health check a service
message HealthCheckRequest {
// Service name to check for its readiness status
optional string service = 1 [ (google.api.field_behavior) = OPTIONAL ];
}

// HealthCheckResponse represents a response for a service heath status
message HealthCheckResponse {
// ServingStatus enumerates the status of a queried service
enum ServingStatus {
// Serving status: UNSPECIFIED
SERVING_STATUS_UNSPECIFIED = 0;
// Serving status: SERVING
SERVING_STATUS_SERVING = 1;
// Serving status: NOT SERVING
SERVING_STATUS_NOT_SERVING = 2;
}

// Status is the instance of the enum type ServingStatus
ServingStatus status = 1;
}

// LivenessRequest represents a request to check a service liveness status
message LivenessRequest {
// HealthCheckRequest message
HealthCheckRequest health_check_request = 1
[ (google.api.field_behavior) = OPTIONAL ];
}

// LivenessResponse represents a response for a service liveness status
message LivenessResponse {
// HealthCheckResponse message
HealthCheckResponse health_check_response = 1;
}

// ReadinessRequest represents a request to check a service readiness status
message ReadinessRequest {
// HealthCheckRequest message
HealthCheckRequest health_check_request = 1
[ (google.api.field_behavior) = OPTIONAL ];
}

// ReadinessResponse represents a response for a service readiness status
message ReadinessResponse {
// HealthCheckResponse message
HealthCheckResponse health_check_response = 1;
}

// OwnerType enumerates the owner type of any resource
enum OwnerType {
// OwnerType: UNSPECIFIED
Expand Down
5 changes: 3 additions & 2 deletions instill/mgmt/v1alpha/mgmt_service.proto
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
syntax = "proto3";

package instill.mgmt.v1alpha;
package mgmt.v1alpha;

// Google API
import "google/api/annotations.proto";
import "google/api/client.proto";

import "instill/mgmt/v1alpha/mgmt.proto";
import "mgmt/v1alpha/healthcheck.proto";
import "mgmt/v1alpha/mgmt.proto";

// User service responds to incoming user requests.
service UserService {
Expand Down
Loading

0 comments on commit 3b33ff4

Please sign in to comment.