From b56fa7c508ff290363365d7af1148814b3280187 Mon Sep 17 00:00:00 2001 From: Alexandre de Souza Date: Tue, 11 Jun 2024 17:13:37 -0300 Subject: [PATCH] Use protobuf Enum exclusively for message sent from Client (#2644) --- .../livebook_proto/app_deployment_status.pb.ex | 2 +- .../app_deployment_status_type.pb.ex | 8 ++++++++ proto/messages.proto | 16 +++++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 proto/lib/livebook_proto/app_deployment_status_type.pb.ex diff --git a/proto/lib/livebook_proto/app_deployment_status.pb.ex b/proto/lib/livebook_proto/app_deployment_status.pb.ex index 608f0c3fd..eaa119a5d 100644 --- a/proto/lib/livebook_proto/app_deployment_status.pb.ex +++ b/proto/lib/livebook_proto/app_deployment_status.pb.ex @@ -4,5 +4,5 @@ defmodule LivebookProto.AppDeploymentStatus do field :id, 1, type: :string field :deployment_group_id, 2, type: :string, json_name: "deploymentGroupId" field :version, 3, type: :string - field :status, 4, type: :string + field :status, 4, type: LivebookProto.AppDeploymentStatusType, enum: true end diff --git a/proto/lib/livebook_proto/app_deployment_status_type.pb.ex b/proto/lib/livebook_proto/app_deployment_status_type.pb.ex new file mode 100644 index 000000000..237947256 --- /dev/null +++ b/proto/lib/livebook_proto/app_deployment_status_type.pb.ex @@ -0,0 +1,8 @@ +defmodule LivebookProto.AppDeploymentStatusType do + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" + + field :connecting, 0 + field :preparing, 1 + field :available, 2 + field :deactivated, 99 +end diff --git a/proto/messages.proto b/proto/messages.proto index d7060aa45..454bf9d5f 100644 --- a/proto/messages.proto +++ b/proto/messages.proto @@ -159,11 +159,25 @@ message Agent { string deployment_group_id = 4; } +/** + * We're only using Enum in this case because + * the Client is the source of the information, + * and the Server will always be up-to-date. + * + * Otherwise, it shouldn't be used. + */ +enum AppDeploymentStatusType { + connecting = 0; + preparing = 1; + available = 2; + deactivated = 4; +} + message AppDeploymentStatus { string id = 1; string deployment_group_id = 2; string version = 3; - string status = 4; + AppDeploymentStatusType status = 4; } message AppDeploymentStatusReport {