feat: backend service
This commit is contained in:
@@ -0,0 +1,432 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc (unknown)
|
||||
// source: push/v1/push.proto
|
||||
|
||||
package pushv1
|
||||
|
||||
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)
|
||||
)
|
||||
|
||||
// GatewaySubscribeRequest opens a push subscription. gateway_client_id
|
||||
// uniquely identifies the gateway instance; backend tracks one
|
||||
// subscription per id and replaces an existing one on reconnect. cursor
|
||||
// is the last consumed PushEvent.cursor; backend resumes from the next
|
||||
// event when the cursor is still inside the freshness-window ring, or
|
||||
// from a fresh point otherwise.
|
||||
type GatewaySubscribeRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
GatewayClientId string `protobuf:"bytes,1,opt,name=gateway_client_id,json=gatewayClientId,proto3" json:"gateway_client_id,omitempty"`
|
||||
Cursor string `protobuf:"bytes,2,opt,name=cursor,proto3" json:"cursor,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GatewaySubscribeRequest) Reset() {
|
||||
*x = GatewaySubscribeRequest{}
|
||||
mi := &file_push_v1_push_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GatewaySubscribeRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GatewaySubscribeRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GatewaySubscribeRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_push_v1_push_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 GatewaySubscribeRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GatewaySubscribeRequest) Descriptor() ([]byte, []int) {
|
||||
return file_push_v1_push_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *GatewaySubscribeRequest) GetGatewayClientId() string {
|
||||
if x != nil {
|
||||
return x.GatewayClientId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GatewaySubscribeRequest) GetCursor() string {
|
||||
if x != nil {
|
||||
return x.Cursor
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// PushEvent is one server-pushed frame. Exactly one of the kind oneof
|
||||
// fields is set. cursor is a monotonically increasing string assigned by
|
||||
// backend at publish time; gateway persists the last cursor it processed
|
||||
// so it can resume after reconnect.
|
||||
type PushEvent struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Types that are valid to be assigned to Kind:
|
||||
//
|
||||
// *PushEvent_ClientEvent
|
||||
// *PushEvent_SessionInvalidation
|
||||
Kind isPushEvent_Kind `protobuf_oneof:"kind"`
|
||||
Cursor string `protobuf:"bytes,3,opt,name=cursor,proto3" json:"cursor,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *PushEvent) Reset() {
|
||||
*x = PushEvent{}
|
||||
mi := &file_push_v1_push_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *PushEvent) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PushEvent) ProtoMessage() {}
|
||||
|
||||
func (x *PushEvent) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_push_v1_push_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 PushEvent.ProtoReflect.Descriptor instead.
|
||||
func (*PushEvent) Descriptor() ([]byte, []int) {
|
||||
return file_push_v1_push_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *PushEvent) GetKind() isPushEvent_Kind {
|
||||
if x != nil {
|
||||
return x.Kind
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *PushEvent) GetClientEvent() *ClientEvent {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*PushEvent_ClientEvent); ok {
|
||||
return x.ClientEvent
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *PushEvent) GetSessionInvalidation() *SessionInvalidation {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*PushEvent_SessionInvalidation); ok {
|
||||
return x.SessionInvalidation
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *PushEvent) GetCursor() string {
|
||||
if x != nil {
|
||||
return x.Cursor
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type isPushEvent_Kind interface {
|
||||
isPushEvent_Kind()
|
||||
}
|
||||
|
||||
type PushEvent_ClientEvent struct {
|
||||
ClientEvent *ClientEvent `protobuf:"bytes,1,opt,name=client_event,json=clientEvent,proto3,oneof"`
|
||||
}
|
||||
|
||||
type PushEvent_SessionInvalidation struct {
|
||||
SessionInvalidation *SessionInvalidation `protobuf:"bytes,2,opt,name=session_invalidation,json=sessionInvalidation,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*PushEvent_ClientEvent) isPushEvent_Kind() {}
|
||||
|
||||
func (*PushEvent_SessionInvalidation) isPushEvent_Kind() {}
|
||||
|
||||
// ClientEvent carries an opaque payload destined for one user_id and
|
||||
// optionally one device_session_id (empty means fan-out to every active
|
||||
// session of user_id). kind is the notification catalog kind from
|
||||
// README §10. payload is the JSON encoding of the producer's payload
|
||||
// map; gateway forwards the bytes inside the signed envelope without
|
||||
// re-interpreting them.
|
||||
//
|
||||
// event_id, request_id and trace_id are correlation identifiers that
|
||||
// gateway carries verbatim into the signed client envelope. event_id is
|
||||
// stable per logical client-facing event (typically the route id of the
|
||||
// notification route that produced the event). request_id and trace_id
|
||||
// are optional and may be empty when the producer has no upstream
|
||||
// correlation to attach.
|
||||
type ClientEvent struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
|
||||
DeviceSessionId string `protobuf:"bytes,2,opt,name=device_session_id,json=deviceSessionId,proto3" json:"device_session_id,omitempty"`
|
||||
Kind string `protobuf:"bytes,3,opt,name=kind,proto3" json:"kind,omitempty"`
|
||||
Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"`
|
||||
EventId string `protobuf:"bytes,5,opt,name=event_id,json=eventId,proto3" json:"event_id,omitempty"`
|
||||
RequestId string `protobuf:"bytes,6,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
TraceId string `protobuf:"bytes,7,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ClientEvent) Reset() {
|
||||
*x = ClientEvent{}
|
||||
mi := &file_push_v1_push_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ClientEvent) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ClientEvent) ProtoMessage() {}
|
||||
|
||||
func (x *ClientEvent) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_push_v1_push_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 ClientEvent.ProtoReflect.Descriptor instead.
|
||||
func (*ClientEvent) Descriptor() ([]byte, []int) {
|
||||
return file_push_v1_push_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *ClientEvent) GetUserId() string {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ClientEvent) GetDeviceSessionId() string {
|
||||
if x != nil {
|
||||
return x.DeviceSessionId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ClientEvent) GetKind() string {
|
||||
if x != nil {
|
||||
return x.Kind
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ClientEvent) GetPayload() []byte {
|
||||
if x != nil {
|
||||
return x.Payload
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ClientEvent) GetEventId() string {
|
||||
if x != nil {
|
||||
return x.EventId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ClientEvent) GetRequestId() string {
|
||||
if x != nil {
|
||||
return x.RequestId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ClientEvent) GetTraceId() string {
|
||||
if x != nil {
|
||||
return x.TraceId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// SessionInvalidation tells gateway to drop active subscriptions and
|
||||
// reject in-flight authenticated requests bound to the affected
|
||||
// sessions. user_id is always set; device_session_id narrows the
|
||||
// invalidation to a single session, empty means revoke every session of
|
||||
// user_id. reason is a free-form code logged by both sides.
|
||||
type SessionInvalidation struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
DeviceSessionId string `protobuf:"bytes,1,opt,name=device_session_id,json=deviceSessionId,proto3" json:"device_session_id,omitempty"`
|
||||
UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
|
||||
Reason string `protobuf:"bytes,3,opt,name=reason,proto3" json:"reason,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SessionInvalidation) Reset() {
|
||||
*x = SessionInvalidation{}
|
||||
mi := &file_push_v1_push_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SessionInvalidation) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SessionInvalidation) ProtoMessage() {}
|
||||
|
||||
func (x *SessionInvalidation) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_push_v1_push_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 SessionInvalidation.ProtoReflect.Descriptor instead.
|
||||
func (*SessionInvalidation) Descriptor() ([]byte, []int) {
|
||||
return file_push_v1_push_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *SessionInvalidation) GetDeviceSessionId() string {
|
||||
if x != nil {
|
||||
return x.DeviceSessionId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SessionInvalidation) GetUserId() string {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SessionInvalidation) GetReason() string {
|
||||
if x != nil {
|
||||
return x.Reason
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_push_v1_push_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_push_v1_push_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x12push/v1/push.proto\x12\x16galaxy.backend.push.v1\"]\n" +
|
||||
"\x17GatewaySubscribeRequest\x12*\n" +
|
||||
"\x11gateway_client_id\x18\x01 \x01(\tR\x0fgatewayClientId\x12\x16\n" +
|
||||
"\x06cursor\x18\x02 \x01(\tR\x06cursor\"\xd7\x01\n" +
|
||||
"\tPushEvent\x12H\n" +
|
||||
"\fclient_event\x18\x01 \x01(\v2#.galaxy.backend.push.v1.ClientEventH\x00R\vclientEvent\x12`\n" +
|
||||
"\x14session_invalidation\x18\x02 \x01(\v2+.galaxy.backend.push.v1.SessionInvalidationH\x00R\x13sessionInvalidation\x12\x16\n" +
|
||||
"\x06cursor\x18\x03 \x01(\tR\x06cursorB\x06\n" +
|
||||
"\x04kind\"\xd5\x01\n" +
|
||||
"\vClientEvent\x12\x17\n" +
|
||||
"\auser_id\x18\x01 \x01(\tR\x06userId\x12*\n" +
|
||||
"\x11device_session_id\x18\x02 \x01(\tR\x0fdeviceSessionId\x12\x12\n" +
|
||||
"\x04kind\x18\x03 \x01(\tR\x04kind\x12\x18\n" +
|
||||
"\apayload\x18\x04 \x01(\fR\apayload\x12\x19\n" +
|
||||
"\bevent_id\x18\x05 \x01(\tR\aeventId\x12\x1d\n" +
|
||||
"\n" +
|
||||
"request_id\x18\x06 \x01(\tR\trequestId\x12\x19\n" +
|
||||
"\btrace_id\x18\a \x01(\tR\atraceId\"r\n" +
|
||||
"\x13SessionInvalidation\x12*\n" +
|
||||
"\x11device_session_id\x18\x01 \x01(\tR\x0fdeviceSessionId\x12\x17\n" +
|
||||
"\auser_id\x18\x02 \x01(\tR\x06userId\x12\x16\n" +
|
||||
"\x06reason\x18\x03 \x01(\tR\x06reason2m\n" +
|
||||
"\x04Push\x12e\n" +
|
||||
"\rSubscribePush\x12/.galaxy.backend.push.v1.GatewaySubscribeRequest\x1a!.galaxy.backend.push.v1.PushEvent0\x01B%Z#galaxy/backend/proto/push/v1;pushv1b\x06proto3"
|
||||
|
||||
var (
|
||||
file_push_v1_push_proto_rawDescOnce sync.Once
|
||||
file_push_v1_push_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_push_v1_push_proto_rawDescGZIP() []byte {
|
||||
file_push_v1_push_proto_rawDescOnce.Do(func() {
|
||||
file_push_v1_push_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_push_v1_push_proto_rawDesc), len(file_push_v1_push_proto_rawDesc)))
|
||||
})
|
||||
return file_push_v1_push_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_push_v1_push_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_push_v1_push_proto_goTypes = []any{
|
||||
(*GatewaySubscribeRequest)(nil), // 0: galaxy.backend.push.v1.GatewaySubscribeRequest
|
||||
(*PushEvent)(nil), // 1: galaxy.backend.push.v1.PushEvent
|
||||
(*ClientEvent)(nil), // 2: galaxy.backend.push.v1.ClientEvent
|
||||
(*SessionInvalidation)(nil), // 3: galaxy.backend.push.v1.SessionInvalidation
|
||||
}
|
||||
var file_push_v1_push_proto_depIdxs = []int32{
|
||||
2, // 0: galaxy.backend.push.v1.PushEvent.client_event:type_name -> galaxy.backend.push.v1.ClientEvent
|
||||
3, // 1: galaxy.backend.push.v1.PushEvent.session_invalidation:type_name -> galaxy.backend.push.v1.SessionInvalidation
|
||||
0, // 2: galaxy.backend.push.v1.Push.SubscribePush:input_type -> galaxy.backend.push.v1.GatewaySubscribeRequest
|
||||
1, // 3: galaxy.backend.push.v1.Push.SubscribePush:output_type -> galaxy.backend.push.v1.PushEvent
|
||||
3, // [3:4] is the sub-list for method output_type
|
||||
2, // [2:3] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension type_name
|
||||
2, // [2:2] is the sub-list for extension extendee
|
||||
0, // [0:2] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_push_v1_push_proto_init() }
|
||||
func file_push_v1_push_proto_init() {
|
||||
if File_push_v1_push_proto != nil {
|
||||
return
|
||||
}
|
||||
file_push_v1_push_proto_msgTypes[1].OneofWrappers = []any{
|
||||
(*PushEvent_ClientEvent)(nil),
|
||||
(*PushEvent_SessionInvalidation)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_push_v1_push_proto_rawDesc), len(file_push_v1_push_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_push_v1_push_proto_goTypes,
|
||||
DependencyIndexes: file_push_v1_push_proto_depIdxs,
|
||||
MessageInfos: file_push_v1_push_proto_msgTypes,
|
||||
}.Build()
|
||||
File_push_v1_push_proto = out.File
|
||||
file_push_v1_push_proto_goTypes = nil
|
||||
file_push_v1_push_proto_depIdxs = nil
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package galaxy.backend.push.v1;
|
||||
|
||||
option go_package = "galaxy/backend/proto/push/v1;pushv1";
|
||||
|
||||
// Push is the unidirectional control channel from backend to gateway.
|
||||
//
|
||||
// Gateway opens SubscribePush once at startup and keeps the stream open.
|
||||
// Backend pushes two classes of events: ClientEvent (opaque payload that
|
||||
// gateway signs and forwards to active client subscriptions) and
|
||||
// SessionInvalidation (instructs gateway to close subscriptions and
|
||||
// reject in-flight requests for the affected sessions).
|
||||
//
|
||||
// See backend/README.md §7 for the runtime contract.
|
||||
service Push {
|
||||
rpc SubscribePush(GatewaySubscribeRequest) returns (stream PushEvent);
|
||||
}
|
||||
|
||||
// GatewaySubscribeRequest opens a push subscription. gateway_client_id
|
||||
// uniquely identifies the gateway instance; backend tracks one
|
||||
// subscription per id and replaces an existing one on reconnect. cursor
|
||||
// is the last consumed PushEvent.cursor; backend resumes from the next
|
||||
// event when the cursor is still inside the freshness-window ring, or
|
||||
// from a fresh point otherwise.
|
||||
message GatewaySubscribeRequest {
|
||||
string gateway_client_id = 1;
|
||||
string cursor = 2;
|
||||
}
|
||||
|
||||
// PushEvent is one server-pushed frame. Exactly one of the kind oneof
|
||||
// fields is set. cursor is a monotonically increasing string assigned by
|
||||
// backend at publish time; gateway persists the last cursor it processed
|
||||
// so it can resume after reconnect.
|
||||
message PushEvent {
|
||||
oneof kind {
|
||||
ClientEvent client_event = 1;
|
||||
SessionInvalidation session_invalidation = 2;
|
||||
}
|
||||
string cursor = 3;
|
||||
}
|
||||
|
||||
// ClientEvent carries an opaque payload destined for one user_id and
|
||||
// optionally one device_session_id (empty means fan-out to every active
|
||||
// session of user_id). kind is the notification catalog kind from
|
||||
// README §10. payload is the JSON encoding of the producer's payload
|
||||
// map; gateway forwards the bytes inside the signed envelope without
|
||||
// re-interpreting them.
|
||||
//
|
||||
// event_id, request_id and trace_id are correlation identifiers that
|
||||
// gateway carries verbatim into the signed client envelope. event_id is
|
||||
// stable per logical client-facing event (typically the route id of the
|
||||
// notification route that produced the event). request_id and trace_id
|
||||
// are optional and may be empty when the producer has no upstream
|
||||
// correlation to attach.
|
||||
message ClientEvent {
|
||||
string user_id = 1;
|
||||
string device_session_id = 2;
|
||||
string kind = 3;
|
||||
bytes payload = 4;
|
||||
string event_id = 5;
|
||||
string request_id = 6;
|
||||
string trace_id = 7;
|
||||
}
|
||||
|
||||
// SessionInvalidation tells gateway to drop active subscriptions and
|
||||
// reject in-flight authenticated requests bound to the affected
|
||||
// sessions. user_id is always set; device_session_id narrows the
|
||||
// invalidation to a single session, empty means revoke every session of
|
||||
// user_id. reason is a free-form code logged by both sides.
|
||||
message SessionInvalidation {
|
||||
string device_session_id = 1;
|
||||
string user_id = 2;
|
||||
string reason = 3;
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.1
|
||||
// - protoc (unknown)
|
||||
// source: push/v1/push.proto
|
||||
|
||||
package pushv1
|
||||
|
||||
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 (
|
||||
Push_SubscribePush_FullMethodName = "/galaxy.backend.push.v1.Push/SubscribePush"
|
||||
)
|
||||
|
||||
// PushClient is the client API for Push 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.
|
||||
//
|
||||
// Push is the unidirectional control channel from backend to gateway.
|
||||
//
|
||||
// Gateway opens SubscribePush once at startup and keeps the stream open.
|
||||
// Backend pushes two classes of events: ClientEvent (opaque payload that
|
||||
// gateway signs and forwards to active client subscriptions) and
|
||||
// SessionInvalidation (instructs gateway to close subscriptions and
|
||||
// reject in-flight requests for the affected sessions).
|
||||
//
|
||||
// See backend/README.md §7 for the runtime contract.
|
||||
type PushClient interface {
|
||||
SubscribePush(ctx context.Context, in *GatewaySubscribeRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[PushEvent], error)
|
||||
}
|
||||
|
||||
type pushClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewPushClient(cc grpc.ClientConnInterface) PushClient {
|
||||
return &pushClient{cc}
|
||||
}
|
||||
|
||||
func (c *pushClient) SubscribePush(ctx context.Context, in *GatewaySubscribeRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[PushEvent], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &Push_ServiceDesc.Streams[0], Push_SubscribePush_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &grpc.GenericClientStream[GatewaySubscribeRequest, PushEvent]{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 Push_SubscribePushClient = grpc.ServerStreamingClient[PushEvent]
|
||||
|
||||
// PushServer is the server API for Push service.
|
||||
// All implementations must embed UnimplementedPushServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// Push is the unidirectional control channel from backend to gateway.
|
||||
//
|
||||
// Gateway opens SubscribePush once at startup and keeps the stream open.
|
||||
// Backend pushes two classes of events: ClientEvent (opaque payload that
|
||||
// gateway signs and forwards to active client subscriptions) and
|
||||
// SessionInvalidation (instructs gateway to close subscriptions and
|
||||
// reject in-flight requests for the affected sessions).
|
||||
//
|
||||
// See backend/README.md §7 for the runtime contract.
|
||||
type PushServer interface {
|
||||
SubscribePush(*GatewaySubscribeRequest, grpc.ServerStreamingServer[PushEvent]) error
|
||||
mustEmbedUnimplementedPushServer()
|
||||
}
|
||||
|
||||
// UnimplementedPushServer 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 UnimplementedPushServer struct{}
|
||||
|
||||
func (UnimplementedPushServer) SubscribePush(*GatewaySubscribeRequest, grpc.ServerStreamingServer[PushEvent]) error {
|
||||
return status.Error(codes.Unimplemented, "method SubscribePush not implemented")
|
||||
}
|
||||
func (UnimplementedPushServer) mustEmbedUnimplementedPushServer() {}
|
||||
func (UnimplementedPushServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafePushServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to PushServer will
|
||||
// result in compilation errors.
|
||||
type UnsafePushServer interface {
|
||||
mustEmbedUnimplementedPushServer()
|
||||
}
|
||||
|
||||
func RegisterPushServer(s grpc.ServiceRegistrar, srv PushServer) {
|
||||
// If the following call panics, it indicates UnimplementedPushServer 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(&Push_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Push_SubscribePush_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(GatewaySubscribeRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(PushServer).SubscribePush(m, &grpc.GenericServerStream[GatewaySubscribeRequest, PushEvent]{ServerStream: stream})
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type Push_SubscribePushServer = grpc.ServerStreamingServer[PushEvent]
|
||||
|
||||
// Push_ServiceDesc is the grpc.ServiceDesc for Push service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Push_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "galaxy.backend.push.v1.Push",
|
||||
HandlerType: (*PushServer)(nil),
|
||||
Methods: []grpc.MethodDesc{},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "SubscribePush",
|
||||
Handler: _Push_SubscribePush_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "push/v1/push.proto",
|
||||
}
|
||||
Reference in New Issue
Block a user