Добавлен gRPC-контракт proto/device_control (TurnOn/TurnOff/SetLevel), общий Go-модуль proto/ для переиспользования сгенерированного кода. device-control-service принимает команды по gRPC, обновляет desired_state в Redis и публикует их в MQTT; слушает devices/+/telemetry и devices/+/ack для отметки живости устройства и обновления reported_state; горутина health-check переводит устройство в offline по таймауту и публикует событие в RabbitMQ (device.status_changed) для будущего notification-service. Проверено сквозным тестом через docker compose: grpcurl TurnOn/SetLevel меняет desired_state и уходит в MQTT, mosquitto_pub с ack обновляет reported_state и статус, health-check автоматически переводит устройство в offline по истечении таймаута.
292 lines
9.5 KiB
Go
292 lines
9.5 KiB
Go
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
// versions:
|
|
// protoc-gen-go v1.36.11
|
|
// protoc v7.35.1
|
|
// source: device_control/device_control.proto
|
|
|
|
package device_control
|
|
|
|
import (
|
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
reflect "reflect"
|
|
sync "sync"
|
|
unsafe "unsafe"
|
|
)
|
|
|
|
const (
|
|
// Verify that this generated code is sufficiently up-to-date.
|
|
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
|
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
)
|
|
|
|
type TurnOnRequest struct {
|
|
state protoimpl.MessageState `protogen:"open.v1"`
|
|
DeviceId string `protobuf:"bytes,1,opt,name=device_id,json=deviceId,proto3" json:"device_id,omitempty"`
|
|
unknownFields protoimpl.UnknownFields
|
|
sizeCache protoimpl.SizeCache
|
|
}
|
|
|
|
func (x *TurnOnRequest) Reset() {
|
|
*x = TurnOnRequest{}
|
|
mi := &file_device_control_device_control_proto_msgTypes[0]
|
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
ms.StoreMessageInfo(mi)
|
|
}
|
|
|
|
func (x *TurnOnRequest) String() string {
|
|
return protoimpl.X.MessageStringOf(x)
|
|
}
|
|
|
|
func (*TurnOnRequest) ProtoMessage() {}
|
|
|
|
func (x *TurnOnRequest) ProtoReflect() protoreflect.Message {
|
|
mi := &file_device_control_device_control_proto_msgTypes[0]
|
|
if x != nil {
|
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
if ms.LoadMessageInfo() == nil {
|
|
ms.StoreMessageInfo(mi)
|
|
}
|
|
return ms
|
|
}
|
|
return mi.MessageOf(x)
|
|
}
|
|
|
|
// Deprecated: Use TurnOnRequest.ProtoReflect.Descriptor instead.
|
|
func (*TurnOnRequest) Descriptor() ([]byte, []int) {
|
|
return file_device_control_device_control_proto_rawDescGZIP(), []int{0}
|
|
}
|
|
|
|
func (x *TurnOnRequest) GetDeviceId() string {
|
|
if x != nil {
|
|
return x.DeviceId
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type TurnOffRequest struct {
|
|
state protoimpl.MessageState `protogen:"open.v1"`
|
|
DeviceId string `protobuf:"bytes,1,opt,name=device_id,json=deviceId,proto3" json:"device_id,omitempty"`
|
|
unknownFields protoimpl.UnknownFields
|
|
sizeCache protoimpl.SizeCache
|
|
}
|
|
|
|
func (x *TurnOffRequest) Reset() {
|
|
*x = TurnOffRequest{}
|
|
mi := &file_device_control_device_control_proto_msgTypes[1]
|
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
ms.StoreMessageInfo(mi)
|
|
}
|
|
|
|
func (x *TurnOffRequest) String() string {
|
|
return protoimpl.X.MessageStringOf(x)
|
|
}
|
|
|
|
func (*TurnOffRequest) ProtoMessage() {}
|
|
|
|
func (x *TurnOffRequest) ProtoReflect() protoreflect.Message {
|
|
mi := &file_device_control_device_control_proto_msgTypes[1]
|
|
if x != nil {
|
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
if ms.LoadMessageInfo() == nil {
|
|
ms.StoreMessageInfo(mi)
|
|
}
|
|
return ms
|
|
}
|
|
return mi.MessageOf(x)
|
|
}
|
|
|
|
// Deprecated: Use TurnOffRequest.ProtoReflect.Descriptor instead.
|
|
func (*TurnOffRequest) Descriptor() ([]byte, []int) {
|
|
return file_device_control_device_control_proto_rawDescGZIP(), []int{1}
|
|
}
|
|
|
|
func (x *TurnOffRequest) GetDeviceId() string {
|
|
if x != nil {
|
|
return x.DeviceId
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type SetLevelRequest struct {
|
|
state protoimpl.MessageState `protogen:"open.v1"`
|
|
DeviceId string `protobuf:"bytes,1,opt,name=device_id,json=deviceId,proto3" json:"device_id,omitempty"`
|
|
Level float64 `protobuf:"fixed64,2,opt,name=level,proto3" json:"level,omitempty"`
|
|
unknownFields protoimpl.UnknownFields
|
|
sizeCache protoimpl.SizeCache
|
|
}
|
|
|
|
func (x *SetLevelRequest) Reset() {
|
|
*x = SetLevelRequest{}
|
|
mi := &file_device_control_device_control_proto_msgTypes[2]
|
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
ms.StoreMessageInfo(mi)
|
|
}
|
|
|
|
func (x *SetLevelRequest) String() string {
|
|
return protoimpl.X.MessageStringOf(x)
|
|
}
|
|
|
|
func (*SetLevelRequest) ProtoMessage() {}
|
|
|
|
func (x *SetLevelRequest) ProtoReflect() protoreflect.Message {
|
|
mi := &file_device_control_device_control_proto_msgTypes[2]
|
|
if x != nil {
|
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
if ms.LoadMessageInfo() == nil {
|
|
ms.StoreMessageInfo(mi)
|
|
}
|
|
return ms
|
|
}
|
|
return mi.MessageOf(x)
|
|
}
|
|
|
|
// Deprecated: Use SetLevelRequest.ProtoReflect.Descriptor instead.
|
|
func (*SetLevelRequest) Descriptor() ([]byte, []int) {
|
|
return file_device_control_device_control_proto_rawDescGZIP(), []int{2}
|
|
}
|
|
|
|
func (x *SetLevelRequest) GetDeviceId() string {
|
|
if x != nil {
|
|
return x.DeviceId
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func (x *SetLevelRequest) GetLevel() float64 {
|
|
if x != nil {
|
|
return x.Level
|
|
}
|
|
return 0
|
|
}
|
|
|
|
type CommandResult struct {
|
|
state protoimpl.MessageState `protogen:"open.v1"`
|
|
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
|
|
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
|
|
unknownFields protoimpl.UnknownFields
|
|
sizeCache protoimpl.SizeCache
|
|
}
|
|
|
|
func (x *CommandResult) Reset() {
|
|
*x = CommandResult{}
|
|
mi := &file_device_control_device_control_proto_msgTypes[3]
|
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
ms.StoreMessageInfo(mi)
|
|
}
|
|
|
|
func (x *CommandResult) String() string {
|
|
return protoimpl.X.MessageStringOf(x)
|
|
}
|
|
|
|
func (*CommandResult) ProtoMessage() {}
|
|
|
|
func (x *CommandResult) ProtoReflect() protoreflect.Message {
|
|
mi := &file_device_control_device_control_proto_msgTypes[3]
|
|
if x != nil {
|
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
if ms.LoadMessageInfo() == nil {
|
|
ms.StoreMessageInfo(mi)
|
|
}
|
|
return ms
|
|
}
|
|
return mi.MessageOf(x)
|
|
}
|
|
|
|
// Deprecated: Use CommandResult.ProtoReflect.Descriptor instead.
|
|
func (*CommandResult) Descriptor() ([]byte, []int) {
|
|
return file_device_control_device_control_proto_rawDescGZIP(), []int{3}
|
|
}
|
|
|
|
func (x *CommandResult) GetSuccess() bool {
|
|
if x != nil {
|
|
return x.Success
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (x *CommandResult) GetError() string {
|
|
if x != nil {
|
|
return x.Error
|
|
}
|
|
return ""
|
|
}
|
|
|
|
var File_device_control_device_control_proto protoreflect.FileDescriptor
|
|
|
|
const file_device_control_device_control_proto_rawDesc = "" +
|
|
"\n" +
|
|
"#device_control/device_control.proto\x12\x0edevice_control\",\n" +
|
|
"\rTurnOnRequest\x12\x1b\n" +
|
|
"\tdevice_id\x18\x01 \x01(\tR\bdeviceId\"-\n" +
|
|
"\x0eTurnOffRequest\x12\x1b\n" +
|
|
"\tdevice_id\x18\x01 \x01(\tR\bdeviceId\"D\n" +
|
|
"\x0fSetLevelRequest\x12\x1b\n" +
|
|
"\tdevice_id\x18\x01 \x01(\tR\bdeviceId\x12\x14\n" +
|
|
"\x05level\x18\x02 \x01(\x01R\x05level\"?\n" +
|
|
"\rCommandResult\x12\x18\n" +
|
|
"\asuccess\x18\x01 \x01(\bR\asuccess\x12\x14\n" +
|
|
"\x05error\x18\x02 \x01(\tR\x05error2\xed\x01\n" +
|
|
"\rDeviceControl\x12F\n" +
|
|
"\x06TurnOn\x12\x1d.device_control.TurnOnRequest\x1a\x1d.device_control.CommandResult\x12H\n" +
|
|
"\aTurnOff\x12\x1e.device_control.TurnOffRequest\x1a\x1d.device_control.CommandResult\x12J\n" +
|
|
"\bSetLevel\x12\x1f.device_control.SetLevelRequest\x1a\x1d.device_control.CommandResultB>Z<git.cactoz.su/cacto/home_automatization/proto/device_controlb\x06proto3"
|
|
|
|
var (
|
|
file_device_control_device_control_proto_rawDescOnce sync.Once
|
|
file_device_control_device_control_proto_rawDescData []byte
|
|
)
|
|
|
|
func file_device_control_device_control_proto_rawDescGZIP() []byte {
|
|
file_device_control_device_control_proto_rawDescOnce.Do(func() {
|
|
file_device_control_device_control_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_device_control_device_control_proto_rawDesc), len(file_device_control_device_control_proto_rawDesc)))
|
|
})
|
|
return file_device_control_device_control_proto_rawDescData
|
|
}
|
|
|
|
var file_device_control_device_control_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
|
var file_device_control_device_control_proto_goTypes = []any{
|
|
(*TurnOnRequest)(nil), // 0: device_control.TurnOnRequest
|
|
(*TurnOffRequest)(nil), // 1: device_control.TurnOffRequest
|
|
(*SetLevelRequest)(nil), // 2: device_control.SetLevelRequest
|
|
(*CommandResult)(nil), // 3: device_control.CommandResult
|
|
}
|
|
var file_device_control_device_control_proto_depIdxs = []int32{
|
|
0, // 0: device_control.DeviceControl.TurnOn:input_type -> device_control.TurnOnRequest
|
|
1, // 1: device_control.DeviceControl.TurnOff:input_type -> device_control.TurnOffRequest
|
|
2, // 2: device_control.DeviceControl.SetLevel:input_type -> device_control.SetLevelRequest
|
|
3, // 3: device_control.DeviceControl.TurnOn:output_type -> device_control.CommandResult
|
|
3, // 4: device_control.DeviceControl.TurnOff:output_type -> device_control.CommandResult
|
|
3, // 5: device_control.DeviceControl.SetLevel:output_type -> device_control.CommandResult
|
|
3, // [3:6] is the sub-list for method output_type
|
|
0, // [0:3] is the sub-list for method input_type
|
|
0, // [0:0] is the sub-list for extension type_name
|
|
0, // [0:0] is the sub-list for extension extendee
|
|
0, // [0:0] is the sub-list for field type_name
|
|
}
|
|
|
|
func init() { file_device_control_device_control_proto_init() }
|
|
func file_device_control_device_control_proto_init() {
|
|
if File_device_control_device_control_proto != nil {
|
|
return
|
|
}
|
|
type x struct{}
|
|
out := protoimpl.TypeBuilder{
|
|
File: protoimpl.DescBuilder{
|
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
RawDescriptor: unsafe.Slice(unsafe.StringData(file_device_control_device_control_proto_rawDesc), len(file_device_control_device_control_proto_rawDesc)),
|
|
NumEnums: 0,
|
|
NumMessages: 4,
|
|
NumExtensions: 0,
|
|
NumServices: 1,
|
|
},
|
|
GoTypes: file_device_control_device_control_proto_goTypes,
|
|
DependencyIndexes: file_device_control_device_control_proto_depIdxs,
|
|
MessageInfos: file_device_control_device_control_proto_msgTypes,
|
|
}.Build()
|
|
File_device_control_device_control_proto = out.File
|
|
file_device_control_device_control_proto_goTypes = nil
|
|
file_device_control_device_control_proto_depIdxs = nil
|
|
}
|