feat(deploy): single-origin path-based deployment + project site
Serve the whole stack behind one host: site at /, game UI at /game/, gateway REST at /api + /healthz, Connect at /rpc (prefix stripped by the edge Caddy). The built artifact is domain-agnostic — the UI talks to the gateway same-origin via relative URLs, so the same bundle runs under any host with no rebuild and with CORS disabled. - Rename the Connect proto service galaxy.gateway.v1.EdgeGateway -> edge.v1.Gateway; regenerate Go + TS; public path /rpc/edge.v1.Gateway. - Move the game UI under base path /game (env BASE_PATH); make the manifest, service-worker scope, WASM loader, and all navigation base-aware via a withBase helper. - Relative API + /rpc Connect prefix; Vite dev proxy mirrors the strip. - Rewrite the edge Caddy (dev + prod) for path-based routing; empty CORS allow-lists (same-origin); single host. - New VitePress project site (site/): i18n en/ru with switcher, LaTeX math, minimal monospace theme; built and served at /. - dev-deploy compose/Makefile + CI (dev-deploy, prod-build, new site-build) build and seed the site; probes hit /, /game/, /healthz. - Sync docs (ARCHITECTURE, gateway README/openapi, dev-deploy & local-dev READMEs, CLAUDE.md, ui/PLAN). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,545 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc (unknown)
|
||||
// source: edge/v1/edge_gateway.proto
|
||||
|
||||
package edgev1
|
||||
|
||||
import (
|
||||
_ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
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 ExecuteCommandRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// protocol_version identifies the request envelope version. The gateway
|
||||
// accepts only the literal "v1" after required-field validation succeeds.
|
||||
ProtocolVersion string `protobuf:"bytes,1,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"`
|
||||
DeviceSessionId string `protobuf:"bytes,2,opt,name=device_session_id,json=deviceSessionId,proto3" json:"device_session_id,omitempty"`
|
||||
MessageType string `protobuf:"bytes,3,opt,name=message_type,json=messageType,proto3" json:"message_type,omitempty"`
|
||||
TimestampMs int64 `protobuf:"varint,4,opt,name=timestamp_ms,json=timestampMs,proto3" json:"timestamp_ms,omitempty"`
|
||||
RequestId string `protobuf:"bytes,5,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
PayloadBytes []byte `protobuf:"bytes,6,opt,name=payload_bytes,json=payloadBytes,proto3" json:"payload_bytes,omitempty"`
|
||||
// payload_hash is the raw 32-byte SHA-256 digest of payload_bytes.
|
||||
PayloadHash []byte `protobuf:"bytes,7,opt,name=payload_hash,json=payloadHash,proto3" json:"payload_hash,omitempty"`
|
||||
Signature []byte `protobuf:"bytes,8,opt,name=signature,proto3" json:"signature,omitempty"`
|
||||
TraceId string `protobuf:"bytes,9,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandRequest) Reset() {
|
||||
*x = ExecuteCommandRequest{}
|
||||
mi := &file_edge_v1_edge_gateway_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ExecuteCommandRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ExecuteCommandRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_edge_v1_edge_gateway_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 ExecuteCommandRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ExecuteCommandRequest) Descriptor() ([]byte, []int) {
|
||||
return file_edge_v1_edge_gateway_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandRequest) GetProtocolVersion() string {
|
||||
if x != nil {
|
||||
return x.ProtocolVersion
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandRequest) GetDeviceSessionId() string {
|
||||
if x != nil {
|
||||
return x.DeviceSessionId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandRequest) GetMessageType() string {
|
||||
if x != nil {
|
||||
return x.MessageType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandRequest) GetTimestampMs() int64 {
|
||||
if x != nil {
|
||||
return x.TimestampMs
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandRequest) GetRequestId() string {
|
||||
if x != nil {
|
||||
return x.RequestId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandRequest) GetPayloadBytes() []byte {
|
||||
if x != nil {
|
||||
return x.PayloadBytes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandRequest) GetPayloadHash() []byte {
|
||||
if x != nil {
|
||||
return x.PayloadHash
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandRequest) GetSignature() []byte {
|
||||
if x != nil {
|
||||
return x.Signature
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandRequest) GetTraceId() string {
|
||||
if x != nil {
|
||||
return x.TraceId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ExecuteCommandResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
ProtocolVersion string `protobuf:"bytes,1,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"`
|
||||
RequestId string `protobuf:"bytes,2,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
TimestampMs int64 `protobuf:"varint,3,opt,name=timestamp_ms,json=timestampMs,proto3" json:"timestamp_ms,omitempty"`
|
||||
ResultCode string `protobuf:"bytes,4,opt,name=result_code,json=resultCode,proto3" json:"result_code,omitempty"`
|
||||
PayloadBytes []byte `protobuf:"bytes,5,opt,name=payload_bytes,json=payloadBytes,proto3" json:"payload_bytes,omitempty"`
|
||||
PayloadHash []byte `protobuf:"bytes,6,opt,name=payload_hash,json=payloadHash,proto3" json:"payload_hash,omitempty"`
|
||||
Signature []byte `protobuf:"bytes,7,opt,name=signature,proto3" json:"signature,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandResponse) Reset() {
|
||||
*x = ExecuteCommandResponse{}
|
||||
mi := &file_edge_v1_edge_gateway_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ExecuteCommandResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ExecuteCommandResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_edge_v1_edge_gateway_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 ExecuteCommandResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ExecuteCommandResponse) Descriptor() ([]byte, []int) {
|
||||
return file_edge_v1_edge_gateway_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandResponse) GetProtocolVersion() string {
|
||||
if x != nil {
|
||||
return x.ProtocolVersion
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandResponse) GetRequestId() string {
|
||||
if x != nil {
|
||||
return x.RequestId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandResponse) GetTimestampMs() int64 {
|
||||
if x != nil {
|
||||
return x.TimestampMs
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandResponse) GetResultCode() string {
|
||||
if x != nil {
|
||||
return x.ResultCode
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandResponse) GetPayloadBytes() []byte {
|
||||
if x != nil {
|
||||
return x.PayloadBytes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandResponse) GetPayloadHash() []byte {
|
||||
if x != nil {
|
||||
return x.PayloadHash
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ExecuteCommandResponse) GetSignature() []byte {
|
||||
if x != nil {
|
||||
return x.Signature
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SubscribeEventsRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// protocol_version identifies the request envelope version. The gateway
|
||||
// accepts only the literal "v1" after required-field validation succeeds.
|
||||
ProtocolVersion string `protobuf:"bytes,1,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"`
|
||||
DeviceSessionId string `protobuf:"bytes,2,opt,name=device_session_id,json=deviceSessionId,proto3" json:"device_session_id,omitempty"`
|
||||
MessageType string `protobuf:"bytes,3,opt,name=message_type,json=messageType,proto3" json:"message_type,omitempty"`
|
||||
TimestampMs int64 `protobuf:"varint,4,opt,name=timestamp_ms,json=timestampMs,proto3" json:"timestamp_ms,omitempty"`
|
||||
RequestId string `protobuf:"bytes,5,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
// payload_hash is the raw 32-byte SHA-256 digest of payload_bytes. Empty
|
||||
// payloads must use the SHA-256 digest of the empty byte slice.
|
||||
PayloadHash []byte `protobuf:"bytes,6,opt,name=payload_hash,json=payloadHash,proto3" json:"payload_hash,omitempty"`
|
||||
Signature []byte `protobuf:"bytes,7,opt,name=signature,proto3" json:"signature,omitempty"`
|
||||
PayloadBytes []byte `protobuf:"bytes,8,opt,name=payload_bytes,json=payloadBytes,proto3" json:"payload_bytes,omitempty"`
|
||||
TraceId string `protobuf:"bytes,9,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SubscribeEventsRequest) Reset() {
|
||||
*x = SubscribeEventsRequest{}
|
||||
mi := &file_edge_v1_edge_gateway_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SubscribeEventsRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SubscribeEventsRequest) ProtoMessage() {}
|
||||
|
||||
func (x *SubscribeEventsRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_edge_v1_edge_gateway_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 SubscribeEventsRequest.ProtoReflect.Descriptor instead.
|
||||
func (*SubscribeEventsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_edge_v1_edge_gateway_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *SubscribeEventsRequest) GetProtocolVersion() string {
|
||||
if x != nil {
|
||||
return x.ProtocolVersion
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SubscribeEventsRequest) GetDeviceSessionId() string {
|
||||
if x != nil {
|
||||
return x.DeviceSessionId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SubscribeEventsRequest) GetMessageType() string {
|
||||
if x != nil {
|
||||
return x.MessageType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SubscribeEventsRequest) GetTimestampMs() int64 {
|
||||
if x != nil {
|
||||
return x.TimestampMs
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SubscribeEventsRequest) GetRequestId() string {
|
||||
if x != nil {
|
||||
return x.RequestId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SubscribeEventsRequest) GetPayloadHash() []byte {
|
||||
if x != nil {
|
||||
return x.PayloadHash
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SubscribeEventsRequest) GetSignature() []byte {
|
||||
if x != nil {
|
||||
return x.Signature
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SubscribeEventsRequest) GetPayloadBytes() []byte {
|
||||
if x != nil {
|
||||
return x.PayloadBytes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SubscribeEventsRequest) GetTraceId() string {
|
||||
if x != nil {
|
||||
return x.TraceId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GatewayEvent struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
EventType string `protobuf:"bytes,1,opt,name=event_type,json=eventType,proto3" json:"event_type,omitempty"`
|
||||
EventId string `protobuf:"bytes,2,opt,name=event_id,json=eventId,proto3" json:"event_id,omitempty"`
|
||||
TimestampMs int64 `protobuf:"varint,3,opt,name=timestamp_ms,json=timestampMs,proto3" json:"timestamp_ms,omitempty"`
|
||||
PayloadBytes []byte `protobuf:"bytes,4,opt,name=payload_bytes,json=payloadBytes,proto3" json:"payload_bytes,omitempty"`
|
||||
PayloadHash []byte `protobuf:"bytes,5,opt,name=payload_hash,json=payloadHash,proto3" json:"payload_hash,omitempty"`
|
||||
Signature []byte `protobuf:"bytes,6,opt,name=signature,proto3" json:"signature,omitempty"`
|
||||
RequestId string `protobuf:"bytes,7,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
TraceId string `protobuf:"bytes,8,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GatewayEvent) Reset() {
|
||||
*x = GatewayEvent{}
|
||||
mi := &file_edge_v1_edge_gateway_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GatewayEvent) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GatewayEvent) ProtoMessage() {}
|
||||
|
||||
func (x *GatewayEvent) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_edge_v1_edge_gateway_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 GatewayEvent.ProtoReflect.Descriptor instead.
|
||||
func (*GatewayEvent) Descriptor() ([]byte, []int) {
|
||||
return file_edge_v1_edge_gateway_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *GatewayEvent) GetEventType() string {
|
||||
if x != nil {
|
||||
return x.EventType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GatewayEvent) GetEventId() string {
|
||||
if x != nil {
|
||||
return x.EventId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GatewayEvent) GetTimestampMs() int64 {
|
||||
if x != nil {
|
||||
return x.TimestampMs
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GatewayEvent) GetPayloadBytes() []byte {
|
||||
if x != nil {
|
||||
return x.PayloadBytes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GatewayEvent) GetPayloadHash() []byte {
|
||||
if x != nil {
|
||||
return x.PayloadHash
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GatewayEvent) GetSignature() []byte {
|
||||
if x != nil {
|
||||
return x.Signature
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GatewayEvent) GetRequestId() string {
|
||||
if x != nil {
|
||||
return x.RequestId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GatewayEvent) GetTraceId() string {
|
||||
if x != nil {
|
||||
return x.TraceId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_edge_v1_edge_gateway_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_edge_v1_edge_gateway_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x1aedge/v1/edge_gateway.proto\x12\aedge.v1\x1a\x1bbuf/validate/validate.proto\"\x9c\x03\n" +
|
||||
"\x15ExecuteCommandRequest\x122\n" +
|
||||
"\x10protocol_version\x18\x01 \x01(\tB\a\xbaH\x04r\x02\x10\x01R\x0fprotocolVersion\x123\n" +
|
||||
"\x11device_session_id\x18\x02 \x01(\tB\a\xbaH\x04r\x02\x10\x01R\x0fdeviceSessionId\x12*\n" +
|
||||
"\fmessage_type\x18\x03 \x01(\tB\a\xbaH\x04r\x02\x10\x01R\vmessageType\x12*\n" +
|
||||
"\ftimestamp_ms\x18\x04 \x01(\x03B\a\xbaH\x04\"\x02 \x00R\vtimestampMs\x12&\n" +
|
||||
"\n" +
|
||||
"request_id\x18\x05 \x01(\tB\a\xbaH\x04r\x02\x10\x01R\trequestId\x12,\n" +
|
||||
"\rpayload_bytes\x18\x06 \x01(\fB\a\xbaH\x04z\x02\x10\x01R\fpayloadBytes\x12*\n" +
|
||||
"\fpayload_hash\x18\a \x01(\fB\a\xbaH\x04z\x02\x10\x01R\vpayloadHash\x12%\n" +
|
||||
"\tsignature\x18\b \x01(\fB\a\xbaH\x04z\x02\x10\x01R\tsignature\x12\x19\n" +
|
||||
"\btrace_id\x18\t \x01(\tR\atraceId\"\x8c\x02\n" +
|
||||
"\x16ExecuteCommandResponse\x12)\n" +
|
||||
"\x10protocol_version\x18\x01 \x01(\tR\x0fprotocolVersion\x12\x1d\n" +
|
||||
"\n" +
|
||||
"request_id\x18\x02 \x01(\tR\trequestId\x12!\n" +
|
||||
"\ftimestamp_ms\x18\x03 \x01(\x03R\vtimestampMs\x12\x1f\n" +
|
||||
"\vresult_code\x18\x04 \x01(\tR\n" +
|
||||
"resultCode\x12#\n" +
|
||||
"\rpayload_bytes\x18\x05 \x01(\fR\fpayloadBytes\x12!\n" +
|
||||
"\fpayload_hash\x18\x06 \x01(\fR\vpayloadHash\x12\x1c\n" +
|
||||
"\tsignature\x18\a \x01(\fR\tsignature\"\x94\x03\n" +
|
||||
"\x16SubscribeEventsRequest\x122\n" +
|
||||
"\x10protocol_version\x18\x01 \x01(\tB\a\xbaH\x04r\x02\x10\x01R\x0fprotocolVersion\x123\n" +
|
||||
"\x11device_session_id\x18\x02 \x01(\tB\a\xbaH\x04r\x02\x10\x01R\x0fdeviceSessionId\x12*\n" +
|
||||
"\fmessage_type\x18\x03 \x01(\tB\a\xbaH\x04r\x02\x10\x01R\vmessageType\x12*\n" +
|
||||
"\ftimestamp_ms\x18\x04 \x01(\x03B\a\xbaH\x04\"\x02 \x00R\vtimestampMs\x12&\n" +
|
||||
"\n" +
|
||||
"request_id\x18\x05 \x01(\tB\a\xbaH\x04r\x02\x10\x01R\trequestId\x12*\n" +
|
||||
"\fpayload_hash\x18\x06 \x01(\fB\a\xbaH\x04z\x02\x10\x01R\vpayloadHash\x12%\n" +
|
||||
"\tsignature\x18\a \x01(\fB\a\xbaH\x04z\x02\x10\x01R\tsignature\x12#\n" +
|
||||
"\rpayload_bytes\x18\b \x01(\fR\fpayloadBytes\x12\x19\n" +
|
||||
"\btrace_id\x18\t \x01(\tR\atraceId\"\x8b\x02\n" +
|
||||
"\fGatewayEvent\x12\x1d\n" +
|
||||
"\n" +
|
||||
"event_type\x18\x01 \x01(\tR\teventType\x12\x19\n" +
|
||||
"\bevent_id\x18\x02 \x01(\tR\aeventId\x12!\n" +
|
||||
"\ftimestamp_ms\x18\x03 \x01(\x03R\vtimestampMs\x12#\n" +
|
||||
"\rpayload_bytes\x18\x04 \x01(\fR\fpayloadBytes\x12!\n" +
|
||||
"\fpayload_hash\x18\x05 \x01(\fR\vpayloadHash\x12\x1c\n" +
|
||||
"\tsignature\x18\x06 \x01(\fR\tsignature\x12\x1d\n" +
|
||||
"\n" +
|
||||
"request_id\x18\a \x01(\tR\trequestId\x12\x19\n" +
|
||||
"\btrace_id\x18\b \x01(\tR\atraceId2\xa9\x01\n" +
|
||||
"\aGateway\x12Q\n" +
|
||||
"\x0eExecuteCommand\x12\x1e.edge.v1.ExecuteCommandRequest\x1a\x1f.edge.v1.ExecuteCommandResponse\x12K\n" +
|
||||
"\x0fSubscribeEvents\x12\x1f.edge.v1.SubscribeEventsRequest\x1a\x15.edge.v1.GatewayEvent0\x01B%Z#galaxy/gateway/proto/edge/v1;edgev1b\x06proto3"
|
||||
|
||||
var (
|
||||
file_edge_v1_edge_gateway_proto_rawDescOnce sync.Once
|
||||
file_edge_v1_edge_gateway_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_edge_v1_edge_gateway_proto_rawDescGZIP() []byte {
|
||||
file_edge_v1_edge_gateway_proto_rawDescOnce.Do(func() {
|
||||
file_edge_v1_edge_gateway_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_edge_v1_edge_gateway_proto_rawDesc), len(file_edge_v1_edge_gateway_proto_rawDesc)))
|
||||
})
|
||||
return file_edge_v1_edge_gateway_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_edge_v1_edge_gateway_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_edge_v1_edge_gateway_proto_goTypes = []any{
|
||||
(*ExecuteCommandRequest)(nil), // 0: edge.v1.ExecuteCommandRequest
|
||||
(*ExecuteCommandResponse)(nil), // 1: edge.v1.ExecuteCommandResponse
|
||||
(*SubscribeEventsRequest)(nil), // 2: edge.v1.SubscribeEventsRequest
|
||||
(*GatewayEvent)(nil), // 3: edge.v1.GatewayEvent
|
||||
}
|
||||
var file_edge_v1_edge_gateway_proto_depIdxs = []int32{
|
||||
0, // 0: edge.v1.Gateway.ExecuteCommand:input_type -> edge.v1.ExecuteCommandRequest
|
||||
2, // 1: edge.v1.Gateway.SubscribeEvents:input_type -> edge.v1.SubscribeEventsRequest
|
||||
1, // 2: edge.v1.Gateway.ExecuteCommand:output_type -> edge.v1.ExecuteCommandResponse
|
||||
3, // 3: edge.v1.Gateway.SubscribeEvents:output_type -> edge.v1.GatewayEvent
|
||||
2, // [2:4] is the sub-list for method output_type
|
||||
0, // [0:2] 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_edge_v1_edge_gateway_proto_init() }
|
||||
func file_edge_v1_edge_gateway_proto_init() {
|
||||
if File_edge_v1_edge_gateway_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_edge_v1_edge_gateway_proto_rawDesc), len(file_edge_v1_edge_gateway_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_edge_v1_edge_gateway_proto_goTypes,
|
||||
DependencyIndexes: file_edge_v1_edge_gateway_proto_depIdxs,
|
||||
MessageInfos: file_edge_v1_edge_gateway_proto_msgTypes,
|
||||
}.Build()
|
||||
File_edge_v1_edge_gateway_proto = out.File
|
||||
file_edge_v1_edge_gateway_proto_goTypes = nil
|
||||
file_edge_v1_edge_gateway_proto_depIdxs = nil
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package edge.v1;
|
||||
|
||||
option go_package = "galaxy/gateway/proto/edge/v1;edgev1";
|
||||
|
||||
import "buf/validate/validate.proto";
|
||||
|
||||
service Gateway {
|
||||
rpc ExecuteCommand(ExecuteCommandRequest) returns (ExecuteCommandResponse);
|
||||
rpc SubscribeEvents(SubscribeEventsRequest) returns (stream GatewayEvent);
|
||||
}
|
||||
|
||||
message ExecuteCommandRequest {
|
||||
// protocol_version identifies the request envelope version. The gateway
|
||||
// accepts only the literal "v1" after required-field validation succeeds.
|
||||
string protocol_version = 1 [(buf.validate.field).string.min_len = 1];
|
||||
string device_session_id = 2 [(buf.validate.field).string.min_len = 1];
|
||||
string message_type = 3 [(buf.validate.field).string.min_len = 1];
|
||||
int64 timestamp_ms = 4 [(buf.validate.field).int64.gt = 0];
|
||||
string request_id = 5 [(buf.validate.field).string.min_len = 1];
|
||||
bytes payload_bytes = 6 [(buf.validate.field).bytes.min_len = 1];
|
||||
// payload_hash is the raw 32-byte SHA-256 digest of payload_bytes.
|
||||
bytes payload_hash = 7 [(buf.validate.field).bytes.min_len = 1];
|
||||
bytes signature = 8 [(buf.validate.field).bytes.min_len = 1];
|
||||
string trace_id = 9;
|
||||
}
|
||||
|
||||
message ExecuteCommandResponse {
|
||||
string protocol_version = 1;
|
||||
string request_id = 2;
|
||||
int64 timestamp_ms = 3;
|
||||
string result_code = 4;
|
||||
bytes payload_bytes = 5;
|
||||
bytes payload_hash = 6;
|
||||
bytes signature = 7;
|
||||
}
|
||||
|
||||
message SubscribeEventsRequest {
|
||||
// protocol_version identifies the request envelope version. The gateway
|
||||
// accepts only the literal "v1" after required-field validation succeeds.
|
||||
string protocol_version = 1 [(buf.validate.field).string.min_len = 1];
|
||||
string device_session_id = 2 [(buf.validate.field).string.min_len = 1];
|
||||
string message_type = 3 [(buf.validate.field).string.min_len = 1];
|
||||
int64 timestamp_ms = 4 [(buf.validate.field).int64.gt = 0];
|
||||
string request_id = 5 [(buf.validate.field).string.min_len = 1];
|
||||
// payload_hash is the raw 32-byte SHA-256 digest of payload_bytes. Empty
|
||||
// payloads must use the SHA-256 digest of the empty byte slice.
|
||||
bytes payload_hash = 6 [(buf.validate.field).bytes.min_len = 1];
|
||||
bytes signature = 7 [(buf.validate.field).bytes.min_len = 1];
|
||||
bytes payload_bytes = 8;
|
||||
string trace_id = 9;
|
||||
}
|
||||
|
||||
message GatewayEvent {
|
||||
string event_type = 1;
|
||||
string event_id = 2;
|
||||
int64 timestamp_ms = 3;
|
||||
bytes payload_bytes = 4;
|
||||
bytes payload_hash = 5;
|
||||
bytes signature = 6;
|
||||
string request_id = 7;
|
||||
string trace_id = 8;
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.1
|
||||
// - protoc (unknown)
|
||||
// source: edge/v1/edge_gateway.proto
|
||||
|
||||
package edgev1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
Gateway_ExecuteCommand_FullMethodName = "/edge.v1.Gateway/ExecuteCommand"
|
||||
Gateway_SubscribeEvents_FullMethodName = "/edge.v1.Gateway/SubscribeEvents"
|
||||
)
|
||||
|
||||
// GatewayClient is the client API for Gateway service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type GatewayClient interface {
|
||||
ExecuteCommand(ctx context.Context, in *ExecuteCommandRequest, opts ...grpc.CallOption) (*ExecuteCommandResponse, error)
|
||||
SubscribeEvents(ctx context.Context, in *SubscribeEventsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[GatewayEvent], error)
|
||||
}
|
||||
|
||||
type gatewayClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewGatewayClient(cc grpc.ClientConnInterface) GatewayClient {
|
||||
return &gatewayClient{cc}
|
||||
}
|
||||
|
||||
func (c *gatewayClient) ExecuteCommand(ctx context.Context, in *ExecuteCommandRequest, opts ...grpc.CallOption) (*ExecuteCommandResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ExecuteCommandResponse)
|
||||
err := c.cc.Invoke(ctx, Gateway_ExecuteCommand_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *gatewayClient) SubscribeEvents(ctx context.Context, in *SubscribeEventsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[GatewayEvent], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &Gateway_ServiceDesc.Streams[0], Gateway_SubscribeEvents_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &grpc.GenericClientStream[SubscribeEventsRequest, GatewayEvent]{ClientStream: stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type Gateway_SubscribeEventsClient = grpc.ServerStreamingClient[GatewayEvent]
|
||||
|
||||
// GatewayServer is the server API for Gateway service.
|
||||
// All implementations must embed UnimplementedGatewayServer
|
||||
// for forward compatibility.
|
||||
type GatewayServer interface {
|
||||
ExecuteCommand(context.Context, *ExecuteCommandRequest) (*ExecuteCommandResponse, error)
|
||||
SubscribeEvents(*SubscribeEventsRequest, grpc.ServerStreamingServer[GatewayEvent]) error
|
||||
mustEmbedUnimplementedGatewayServer()
|
||||
}
|
||||
|
||||
// UnimplementedGatewayServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedGatewayServer struct{}
|
||||
|
||||
func (UnimplementedGatewayServer) ExecuteCommand(context.Context, *ExecuteCommandRequest) (*ExecuteCommandResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ExecuteCommand not implemented")
|
||||
}
|
||||
func (UnimplementedGatewayServer) SubscribeEvents(*SubscribeEventsRequest, grpc.ServerStreamingServer[GatewayEvent]) error {
|
||||
return status.Error(codes.Unimplemented, "method SubscribeEvents not implemented")
|
||||
}
|
||||
func (UnimplementedGatewayServer) mustEmbedUnimplementedGatewayServer() {}
|
||||
func (UnimplementedGatewayServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeGatewayServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to GatewayServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeGatewayServer interface {
|
||||
mustEmbedUnimplementedGatewayServer()
|
||||
}
|
||||
|
||||
func RegisterGatewayServer(s grpc.ServiceRegistrar, srv GatewayServer) {
|
||||
// If the following call panics, it indicates UnimplementedGatewayServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&Gateway_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Gateway_ExecuteCommand_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ExecuteCommandRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(GatewayServer).ExecuteCommand(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Gateway_ExecuteCommand_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(GatewayServer).ExecuteCommand(ctx, req.(*ExecuteCommandRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Gateway_SubscribeEvents_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(SubscribeEventsRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(GatewayServer).SubscribeEvents(m, &grpc.GenericServerStream[SubscribeEventsRequest, GatewayEvent]{ServerStream: stream})
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type Gateway_SubscribeEventsServer = grpc.ServerStreamingServer[GatewayEvent]
|
||||
|
||||
// Gateway_ServiceDesc is the grpc.ServiceDesc for Gateway service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Gateway_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "edge.v1.Gateway",
|
||||
HandlerType: (*GatewayServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "ExecuteCommand",
|
||||
Handler: _Gateway_ExecuteCommand_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "SubscribeEvents",
|
||||
Handler: _Gateway_SubscribeEvents_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "edge/v1/edge_gateway.proto",
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: edge/v1/edge_gateway.proto
|
||||
|
||||
package edgev1connect
|
||||
|
||||
import (
|
||||
connect "connectrpc.com/connect"
|
||||
context "context"
|
||||
errors "errors"
|
||||
v1 "galaxy/gateway/proto/edge/v1"
|
||||
http "net/http"
|
||||
strings "strings"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file and the connect package are
|
||||
// compatible. If you get a compiler error that this constant is not defined, this code was
|
||||
// generated with a version of connect newer than the one compiled into your binary. You can fix the
|
||||
// problem by either regenerating this code with an older version of connect or updating the connect
|
||||
// version compiled into your binary.
|
||||
const _ = connect.IsAtLeastVersion1_13_0
|
||||
|
||||
const (
|
||||
// GatewayName is the fully-qualified name of the Gateway service.
|
||||
GatewayName = "edge.v1.Gateway"
|
||||
)
|
||||
|
||||
// These constants are the fully-qualified names of the RPCs defined in this package. They're
|
||||
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
|
||||
//
|
||||
// Note that these are different from the fully-qualified method names used by
|
||||
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
|
||||
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
|
||||
// period.
|
||||
const (
|
||||
// GatewayExecuteCommandProcedure is the fully-qualified name of the Gateway's ExecuteCommand RPC.
|
||||
GatewayExecuteCommandProcedure = "/edge.v1.Gateway/ExecuteCommand"
|
||||
// GatewaySubscribeEventsProcedure is the fully-qualified name of the Gateway's SubscribeEvents RPC.
|
||||
GatewaySubscribeEventsProcedure = "/edge.v1.Gateway/SubscribeEvents"
|
||||
)
|
||||
|
||||
// GatewayClient is a client for the edge.v1.Gateway service.
|
||||
type GatewayClient interface {
|
||||
ExecuteCommand(context.Context, *connect.Request[v1.ExecuteCommandRequest]) (*connect.Response[v1.ExecuteCommandResponse], error)
|
||||
SubscribeEvents(context.Context, *connect.Request[v1.SubscribeEventsRequest]) (*connect.ServerStreamForClient[v1.GatewayEvent], error)
|
||||
}
|
||||
|
||||
// NewGatewayClient constructs a client for the edge.v1.Gateway service. By default, it uses the
|
||||
// Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
|
||||
// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
|
||||
// connect.WithGRPCWeb() options.
|
||||
//
|
||||
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
|
||||
// http://api.acme.com or https://acme.com/grpc).
|
||||
func NewGatewayClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) GatewayClient {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
gatewayMethods := v1.File_edge_v1_edge_gateway_proto.Services().ByName("Gateway").Methods()
|
||||
return &gatewayClient{
|
||||
executeCommand: connect.NewClient[v1.ExecuteCommandRequest, v1.ExecuteCommandResponse](
|
||||
httpClient,
|
||||
baseURL+GatewayExecuteCommandProcedure,
|
||||
connect.WithSchema(gatewayMethods.ByName("ExecuteCommand")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
subscribeEvents: connect.NewClient[v1.SubscribeEventsRequest, v1.GatewayEvent](
|
||||
httpClient,
|
||||
baseURL+GatewaySubscribeEventsProcedure,
|
||||
connect.WithSchema(gatewayMethods.ByName("SubscribeEvents")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// gatewayClient implements GatewayClient.
|
||||
type gatewayClient struct {
|
||||
executeCommand *connect.Client[v1.ExecuteCommandRequest, v1.ExecuteCommandResponse]
|
||||
subscribeEvents *connect.Client[v1.SubscribeEventsRequest, v1.GatewayEvent]
|
||||
}
|
||||
|
||||
// ExecuteCommand calls edge.v1.Gateway.ExecuteCommand.
|
||||
func (c *gatewayClient) ExecuteCommand(ctx context.Context, req *connect.Request[v1.ExecuteCommandRequest]) (*connect.Response[v1.ExecuteCommandResponse], error) {
|
||||
return c.executeCommand.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SubscribeEvents calls edge.v1.Gateway.SubscribeEvents.
|
||||
func (c *gatewayClient) SubscribeEvents(ctx context.Context, req *connect.Request[v1.SubscribeEventsRequest]) (*connect.ServerStreamForClient[v1.GatewayEvent], error) {
|
||||
return c.subscribeEvents.CallServerStream(ctx, req)
|
||||
}
|
||||
|
||||
// GatewayHandler is an implementation of the edge.v1.Gateway service.
|
||||
type GatewayHandler interface {
|
||||
ExecuteCommand(context.Context, *connect.Request[v1.ExecuteCommandRequest]) (*connect.Response[v1.ExecuteCommandResponse], error)
|
||||
SubscribeEvents(context.Context, *connect.Request[v1.SubscribeEventsRequest], *connect.ServerStream[v1.GatewayEvent]) error
|
||||
}
|
||||
|
||||
// NewGatewayHandler builds an HTTP handler from the service implementation. It returns the path on
|
||||
// which to mount the handler and the handler itself.
|
||||
//
|
||||
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
|
||||
// and JSON codecs. They also support gzip compression.
|
||||
func NewGatewayHandler(svc GatewayHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
gatewayMethods := v1.File_edge_v1_edge_gateway_proto.Services().ByName("Gateway").Methods()
|
||||
gatewayExecuteCommandHandler := connect.NewUnaryHandler(
|
||||
GatewayExecuteCommandProcedure,
|
||||
svc.ExecuteCommand,
|
||||
connect.WithSchema(gatewayMethods.ByName("ExecuteCommand")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
gatewaySubscribeEventsHandler := connect.NewServerStreamHandler(
|
||||
GatewaySubscribeEventsProcedure,
|
||||
svc.SubscribeEvents,
|
||||
connect.WithSchema(gatewayMethods.ByName("SubscribeEvents")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/edge.v1.Gateway/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case GatewayExecuteCommandProcedure:
|
||||
gatewayExecuteCommandHandler.ServeHTTP(w, r)
|
||||
case GatewaySubscribeEventsProcedure:
|
||||
gatewaySubscribeEventsHandler.ServeHTTP(w, r)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// UnimplementedGatewayHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedGatewayHandler struct{}
|
||||
|
||||
func (UnimplementedGatewayHandler) ExecuteCommand(context.Context, *connect.Request[v1.ExecuteCommandRequest]) (*connect.Response[v1.ExecuteCommandResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("edge.v1.Gateway.ExecuteCommand is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedGatewayHandler) SubscribeEvents(context.Context, *connect.Request[v1.SubscribeEventsRequest], *connect.ServerStream[v1.GatewayEvent]) error {
|
||||
return connect.NewError(connect.CodeUnimplemented, errors.New("edge.v1.Gateway.SubscribeEvents is not implemented"))
|
||||
}
|
||||
Reference in New Issue
Block a user