-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Because - this is for usage collection This commit - add `usage` package
- Loading branch information
1 parent
5e52261
commit 15a5103
Showing
3 changed files
with
383 additions
and
9 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 |
---|---|---|
@@ -0,0 +1,128 @@ | ||
syntax = "proto3"; | ||
|
||
package instill.usage.v1alpha; | ||
|
||
// Protobuf standard | ||
import "google/protobuf/timestamp.proto"; | ||
|
||
// Google API | ||
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; | ||
} | ||
|
||
// Session represents a unique session whenever a new instance of VDP gets | ||
// started. The usage server returns a token for the given pair of identifiers | ||
// (`cluster_id` and `server_id`) that should be used as part of the challenge | ||
// when creating a report | ||
message Session { | ||
option (google.api.resource) = { | ||
type : "api.instill.tech/Session" | ||
pattern : "sessions/{session}" | ||
}; | ||
|
||
// Permalink of a session. It must have the format of "sessons/{uid}" | ||
string permalink = 1 [ (google.api.field_behavior) = OUTPUT_ONLY ]; | ||
// Session ID in UUIDv4 | ||
string uid = 2 [ (google.api.field_behavior) = OUTPUT_ONLY ]; | ||
// Cluster Identifier | ||
string cluster_id = 3 [ (google.api.field_behavior) = INPUT_ONLY ]; | ||
// Server Identifier | ||
string server_id = 4 [ (google.api.field_behavior) = INPUT_ONLY ]; | ||
// Token to send report. The token is generated by the server and sent to the | ||
// client. Client needs to use the token to send report to the server. | ||
string token = 5; | ||
} | ||
|
||
// UsageData represents the usage data collected from a session | ||
message UsageData { | ||
// Session | ||
Session session = 1 [ (google.api.field_behavior) = REQUIRED ]; | ||
// Version of the system | ||
string version = 2 [ (google.api.field_behavior) = REQUIRED ]; | ||
// Architecture of the system | ||
string arch = 3 [ (google.api.field_behavior) = REQUIRED ]; | ||
// Operating system | ||
string os = 4 [ (google.api.field_behavior) = REQUIRED ]; | ||
// Session service uptime | ||
int64 uptime = 5 [ (google.api.field_behavior) = REQUIRED ]; | ||
// Report time | ||
google.protobuf.Timestamp time = 6 [ (google.api.field_behavior) = REQUIRED ]; | ||
} | ||
|
||
// Report represents a report to be sent to the server that includes the usage | ||
// data of a session | ||
message Report { | ||
// Permalink of a report. It must have the format of "reports/{uid}" | ||
string permalink = 1 [ (google.api.field_behavior) = OUTPUT_ONLY ]; | ||
// Report ID in UUIDv4 | ||
string uid = 2 [ (google.api.field_behavior) = OUTPUT_ONLY ]; | ||
// Pow | ||
string pow = 3 [ (google.api.field_behavior) = REQUIRED ]; | ||
// Usage data | ||
UsageData data = 4 [ (google.api.field_behavior) = REQUIRED ]; | ||
} | ||
|
||
// CreateSessionRequest represents a request to create a new session | ||
message CreateSessionRequest { | ||
// A session resource to create | ||
Session session = 1 [ (google.api.field_behavior) = REQUIRED ]; | ||
} | ||
// CreateSessionResponse represents a response for a session response | ||
message CreateSessionResponse { | ||
// A session resource | ||
Session session = 1; | ||
} | ||
// SendReportRequest represents a request to send a usage report | ||
message SendReportRequest { | ||
// A report resource to create | ||
Report report = 1 [ (google.api.field_behavior) = REQUIRED ]; | ||
} | ||
// SendReportResponse represents an empty response | ||
message SendReportResponse {} |
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,50 @@ | ||
syntax = "proto3"; | ||
|
||
package instill.usage.v1alpha; | ||
|
||
// Google API | ||
import "google/api/annotations.proto"; | ||
import "google/api/client.proto"; | ||
|
||
import "instill/usage/v1alpha/usage.proto"; | ||
|
||
// UsageService responds to incoming usage requests. | ||
service UsageService { | ||
// Liveness method receives a LivenessRequest message and returns a | ||
// LivenessResponse message. | ||
// See https://github.com/grpc/grpc/blob/master/doc/health-checking.md | ||
rpc Liveness(LivenessRequest) returns (LivenessResponse) { | ||
option (google.api.http) = { | ||
get : "/v1alpha/__liveness" | ||
additional_bindings : [ {get : "/v1alpha/health/mgmt"} ] | ||
}; | ||
} | ||
|
||
// Readiness method receives a ReadinessRequest message and returns a | ||
// ReadinessResponse message. | ||
// See https://github.com/grpc/grpc/blob/master/doc/health-checking.md | ||
rpc Readiness(ReadinessRequest) returns (ReadinessResponse) { | ||
option (google.api.http) = { | ||
get : "/v1alpha/__readiness" | ||
}; | ||
} | ||
|
||
// CreateSession method receives a CreateSessionRequest message and returns | ||
// a CreateSessionResponse message. | ||
rpc CreateSession(CreateSessionRequest) returns (CreateSessionResponse) { | ||
option (google.api.http) = { | ||
post : "/v1alpha/sessions" | ||
body : "session" | ||
}; | ||
option (google.api.method_signature) = "session"; | ||
} | ||
|
||
// SendReport method receives a SendReportRequest message and returns a | ||
// SendReportResponse message. | ||
rpc SendReport(SendReportRequest) returns (SendReportResponse) { | ||
option (google.api.http) = { | ||
post : "/v1alpha/reports:send" | ||
body : "*" | ||
}; | ||
} | ||
} |
Oops, something went wrong.