Skip to content

Commit

Permalink
feat: Add subscribe interface (#2037)
Browse files Browse the repository at this point in the history
  • Loading branch information
chubei authored Sep 14, 2023
1 parent 6533f93 commit 82a42f2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dozer-cli/src/simple/cloud/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ impl LoginSvc {
auth_url: self.auth_url.to_owned(),
};

credential_info.get_access_token().await?;
let token = credential_info.get_access_token().await?;
println!("Temporary bearer token: {}\n", token.access_token);
credential_info.save()?;
println!("Login success !");
Ok(())
Expand Down
4 changes: 4 additions & 0 deletions dozer-types/protos/cloud.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
syntax = "proto3";
package dozer.cloud;
import "cloud_types.proto";
import "cloud_notification.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";

service DozerCloud {
rpc create_application(CreateAppRequest) returns (AppResponse);
Expand Down Expand Up @@ -41,6 +43,8 @@ service DozerCloud {
rpc OnStatusUpdate(StatusUpdateRequest) returns (stream StatusUpdate);

rpc get_resources(GetResourcesRequest) returns (ResourcesResponse);

rpc Subscribe(google.protobuf.Empty) returns (stream Notification);
}

service DozerPublic {
Expand Down
51 changes: 51 additions & 0 deletions dozer-types/protos/cloud_notification.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
syntax = "proto3";
package dozer.cloud;

message Notification {
string namespace = 1;
Level level = 2;
oneof kind {
PodNotification pod = 3;
}
}

enum Level {
TRACE = 0;
DEBUG = 1;
INFO = 2;
WARN = 3;
ERROR = 4;
}

message PodNotification {
uint32 deployment = 1;
oneof kind {
ContainerTerminated containerTerminated = 2;
}
}

message ContainerTerminated {
ContainerTerminationKind kind = 1;
ContainerTerminationReason reason = 2;
ContainerTerminationDetail detail = 3;
}

enum ContainerTerminationKind {
APP_FAILED = 0;
APP_RESTARTED = 1;
API_RESTARTED = 2;
CACHE_BACKUP_RESTARTED = 3;
}

enum ContainerTerminationReason {
OUT_OF_MEMORY = 0;
OUT_OF_STORAGE = 1;
UNKNOWN = 2;
}

message ContainerTerminationDetail {
int32 exitCode = 1;
optional string message = 2;
optional string reason = 3;
optional int32 signal = 4;
}

0 comments on commit 82a42f2

Please sign in to comment.