Compare commits

..
5 Commits
5 changed files with 57 additions and 4 deletions

No files matched your search

+11 -2
View File
@@ -71,6 +71,7 @@ type Message struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
Type RequestType `protobuf:"varint,2,opt,name=type,proto3,enum=proto.RequestType" json:"type,omitempty"` Type RequestType `protobuf:"varint,2,opt,name=type,proto3,enum=proto.RequestType" json:"type,omitempty"`
ClientId string `protobuf:"bytes,3,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@@ -119,15 +120,23 @@ func (x *Message) GetType() RequestType {
return RequestType_PING return RequestType_PING
} }
func (x *Message) GetClientId() string {
if x != nil {
return x.ClientId
}
return ""
}
var File_operation_proto protoreflect.FileDescriptor var File_operation_proto protoreflect.FileDescriptor
const file_operation_proto_rawDesc = "" + const file_operation_proto_rawDesc = "" +
"\n" + "\n" +
"\x0foperation.proto\x12\x05proto\"P\n" + "\x0foperation.proto\x12\x05proto\"m\n" +
"\aMessage\x12\x1d\n" + "\aMessage\x12\x1d\n" +
"\n" + "\n" +
"request_id\x18\x01 \x01(\tR\trequestId\x12&\n" + "request_id\x18\x01 \x01(\tR\trequestId\x12&\n" +
"\x04type\x18\x02 \x01(\x0e2\x12.proto.RequestTypeR\x04type*'\n" + "\x04type\x18\x02 \x01(\x0e2\x12.proto.RequestTypeR\x04type\x12\x1b\n" +
"\tclient_id\x18\x03 \x01(\tR\bclientId*'\n" +
"\vRequestType\x12\b\n" + "\vRequestType\x12\b\n" +
"\x04PING\x10\x00\x12\x0e\n" + "\x04PING\x10\x00\x12\x0e\n" +
"\n" + "\n" +
+1
View File
@@ -11,4 +11,5 @@ enum RequestType {
message Message { message Message {
string request_id = 1; string request_id = 1;
RequestType type = 2; RequestType type = 2;
string client_id = 3;
} }
+11 -2
View File
@@ -75,6 +75,7 @@ type Deployment struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Action DeploymentAction `protobuf:"varint,2,opt,name=action,proto3,enum=proto.DeploymentAction" json:"action,omitempty"` Action DeploymentAction `protobuf:"varint,2,opt,name=action,proto3,enum=proto.DeploymentAction" json:"action,omitempty"`
Hcl []byte `protobuf:"bytes,3,opt,name=hcl,proto3" json:"hcl,omitempty"` Hcl []byte `protobuf:"bytes,3,opt,name=hcl,proto3" json:"hcl,omitempty"`
ClientId string `protobuf:"bytes,4,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@@ -130,16 +131,24 @@ func (x *Deployment) GetHcl() []byte {
return nil return nil
} }
func (x *Deployment) GetClientId() string {
if x != nil {
return x.ClientId
}
return ""
}
var File_deployment_proto protoreflect.FileDescriptor var File_deployment_proto protoreflect.FileDescriptor
const file_deployment_proto_rawDesc = "" + const file_deployment_proto_rawDesc = "" +
"\n" + "\n" +
"\x10deployment.proto\x12\x05proto\"_\n" + "\x10deployment.proto\x12\x05proto\"|\n" +
"\n" + "\n" +
"Deployment\x12\x0e\n" + "Deployment\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12/\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12/\n" +
"\x06action\x18\x02 \x01(\x0e2\x17.proto.DeploymentActionR\x06action\x12\x10\n" + "\x06action\x18\x02 \x01(\x0e2\x17.proto.DeploymentActionR\x06action\x12\x10\n" +
"\x03hcl\x18\x03 \x01(\fR\x03hcl*4\n" + "\x03hcl\x18\x03 \x01(\fR\x03hcl\x12\x1b\n" +
"\tclient_id\x18\x04 \x01(\tR\bclientId*4\n" +
"\x10DeploymentAction\x12\b\n" + "\x10DeploymentAction\x12\b\n" +
"\x04STOP\x10\x00\x12\t\n" + "\x04STOP\x10\x00\x12\t\n" +
"\x05START\x10\x01\x12\v\n" + "\x05START\x10\x01\x12\v\n" +
+1
View File
@@ -13,4 +13,5 @@ message Deployment {
string id = 1; string id = 1;
DeploymentAction action = 2; DeploymentAction action = 2;
bytes hcl = 3; bytes hcl = 3;
string client_id = 4;
} }
+33
View File
@@ -0,0 +1,33 @@
package model
const (
topicOperation = "op"
topicDeployment = "deployment"
)
// QOS is the predefined Quality of Service level for MQTT messages.
//
//goland:noinspection GoUnusedConst
const QOS = 2
// OperationTopic returns the topic for operation messages for a given client ID.
//
//goland:noinspection GoUnusedExportedFunction
func OperationTopic(clientId string) string {
return makeTopic(clientId, topicOperation)
}
// DeploymentTopic returns the topic for deployment messages for a given client ID.
//
//goland:noinspection GoUnusedExportedFunction
func DeploymentTopic(clientId string) string {
return makeTopic(clientId, topicDeployment)
}
func makeTopic(clientId, topic string) string {
if clientId != "" {
clientId += "/"
}
return clientId + topic
}