✨ Websocket stream control count connection for specific user
This commit is contained in:
parent
8f996bb697
commit
7812a06cb1
@ -7,6 +7,13 @@ import (
|
|||||||
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
|
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (v *Server) CountStreamConnection(ctx context.Context, request *proto.CountConnectionRequest) (*proto.CountConnectionResponse, error) {
|
||||||
|
out := services.ClientCount(uint(request.GetUserId()))
|
||||||
|
return &proto.CountConnectionResponse{
|
||||||
|
Count: int64(out),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (v *Server) PushStream(ctx context.Context, request *proto.PushStreamRequest) (*proto.PushStreamResponse, error) {
|
func (v *Server) PushStream(ctx context.Context, request *proto.PushStreamRequest) (*proto.PushStreamResponse, error) {
|
||||||
cnt, success, errs := services.WebsocketPush(uint(request.GetUserId()), request.GetBody())
|
cnt, success, errs := services.WebsocketPush(uint(request.GetUserId()), request.GetBody())
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
|
@ -29,6 +29,10 @@ func ClientUnregister(user models.Account, conn *websocket.Conn) {
|
|||||||
wsMutex.Unlock()
|
wsMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ClientCount(uid uint) int {
|
||||||
|
return len(wsConn[uid])
|
||||||
|
}
|
||||||
|
|
||||||
func WebsocketPush(uid uint, body []byte) (count int, success int, errs []error) {
|
func WebsocketPush(uid uint, body []byte) (count int, success int, errs []error) {
|
||||||
for conn := range wsConn[uid] {
|
for conn := range wsConn[uid] {
|
||||||
if err := conn.WriteMessage(1, body); err != nil {
|
if err := conn.WriteMessage(1, body); err != nil {
|
||||||
|
@ -20,6 +20,100 @@ const (
|
|||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type CountConnectionRequest struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
UserId uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CountConnectionRequest) Reset() {
|
||||||
|
*x = CountConnectionRequest{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_stream_proto_msgTypes[0]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CountConnectionRequest) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*CountConnectionRequest) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *CountConnectionRequest) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_stream_proto_msgTypes[0]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use CountConnectionRequest.ProtoReflect.Descriptor instead.
|
||||||
|
func (*CountConnectionRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return file_stream_proto_rawDescGZIP(), []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CountConnectionRequest) GetUserId() uint64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.UserId
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type CountConnectionResponse struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CountConnectionResponse) Reset() {
|
||||||
|
*x = CountConnectionResponse{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_stream_proto_msgTypes[1]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CountConnectionResponse) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*CountConnectionResponse) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *CountConnectionResponse) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_stream_proto_msgTypes[1]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use CountConnectionResponse.ProtoReflect.Descriptor instead.
|
||||||
|
func (*CountConnectionResponse) Descriptor() ([]byte, []int) {
|
||||||
|
return file_stream_proto_rawDescGZIP(), []int{1}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CountConnectionResponse) GetCount() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Count
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
type PushStreamRequest struct {
|
type PushStreamRequest struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
@ -32,7 +126,7 @@ type PushStreamRequest struct {
|
|||||||
func (x *PushStreamRequest) Reset() {
|
func (x *PushStreamRequest) Reset() {
|
||||||
*x = PushStreamRequest{}
|
*x = PushStreamRequest{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_stream_proto_msgTypes[0]
|
mi := &file_stream_proto_msgTypes[2]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@ -45,7 +139,7 @@ func (x *PushStreamRequest) String() string {
|
|||||||
func (*PushStreamRequest) ProtoMessage() {}
|
func (*PushStreamRequest) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *PushStreamRequest) ProtoReflect() protoreflect.Message {
|
func (x *PushStreamRequest) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_stream_proto_msgTypes[0]
|
mi := &file_stream_proto_msgTypes[2]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@ -58,7 +152,7 @@ func (x *PushStreamRequest) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use PushStreamRequest.ProtoReflect.Descriptor instead.
|
// Deprecated: Use PushStreamRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*PushStreamRequest) Descriptor() ([]byte, []int) {
|
func (*PushStreamRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_stream_proto_rawDescGZIP(), []int{0}
|
return file_stream_proto_rawDescGZIP(), []int{2}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PushStreamRequest) GetUserId() uint64 {
|
func (x *PushStreamRequest) GetUserId() uint64 {
|
||||||
@ -88,7 +182,7 @@ type PushStreamResponse struct {
|
|||||||
func (x *PushStreamResponse) Reset() {
|
func (x *PushStreamResponse) Reset() {
|
||||||
*x = PushStreamResponse{}
|
*x = PushStreamResponse{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_stream_proto_msgTypes[1]
|
mi := &file_stream_proto_msgTypes[3]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@ -101,7 +195,7 @@ func (x *PushStreamResponse) String() string {
|
|||||||
func (*PushStreamResponse) ProtoMessage() {}
|
func (*PushStreamResponse) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *PushStreamResponse) ProtoReflect() protoreflect.Message {
|
func (x *PushStreamResponse) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_stream_proto_msgTypes[1]
|
mi := &file_stream_proto_msgTypes[3]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@ -114,7 +208,7 @@ func (x *PushStreamResponse) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use PushStreamResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use PushStreamResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*PushStreamResponse) Descriptor() ([]byte, []int) {
|
func (*PushStreamResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_stream_proto_rawDescGZIP(), []int{1}
|
return file_stream_proto_rawDescGZIP(), []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PushStreamResponse) GetIsAllSuccess() bool {
|
func (x *PushStreamResponse) GetIsAllSuccess() bool {
|
||||||
@ -142,26 +236,38 @@ var File_stream_proto protoreflect.FileDescriptor
|
|||||||
|
|
||||||
var file_stream_proto_rawDesc = []byte{
|
var file_stream_proto_rawDesc = []byte{
|
||||||
0x0a, 0x0c, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05,
|
0x0a, 0x0c, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05,
|
||||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x40, 0x0a, 0x11, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72,
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x31, 0x0a, 0x16, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x43, 0x6f,
|
||||||
0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73,
|
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
|
||||||
0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65,
|
0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04,
|
||||||
0x72, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28,
|
0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x2f, 0x0a, 0x17, 0x43, 0x6f, 0x75, 0x6e,
|
||||||
0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x84, 0x01, 0x0a, 0x12, 0x50, 0x75, 0x73, 0x68,
|
0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||||
0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24,
|
0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x0a, 0x0e, 0x69, 0x73, 0x5f, 0x61, 0x6c, 0x6c, 0x5f, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73,
|
0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x40, 0x0a, 0x11, 0x50, 0x75, 0x73,
|
||||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x69, 0x73, 0x41, 0x6c, 0x6c, 0x53, 0x75, 0x63,
|
0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17,
|
||||||
0x63, 0x65, 0x73, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64,
|
0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52,
|
||||||
0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x61, 0x66,
|
0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18,
|
||||||
0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x66,
|
0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x84, 0x01, 0x0a, 0x12,
|
||||||
0x61, 0x69, 0x6c, 0x65, 0x64, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28,
|
0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||||
0x03, 0x52, 0x0b, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0x57,
|
0x73, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x69, 0x73, 0x5f, 0x61, 0x6c, 0x6c, 0x5f, 0x73, 0x75, 0x63,
|
||||||
0x0a, 0x10, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c,
|
0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x69, 0x73, 0x41, 0x6c,
|
||||||
0x65, 0x72, 0x12, 0x43, 0x0a, 0x0a, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d,
|
0x6c, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x66, 0x66, 0x65,
|
||||||
0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72,
|
0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03,
|
||||||
0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f,
|
0x52, 0x0d, 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12,
|
||||||
0x74, 0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73,
|
0x21, 0x0a, 0x0c, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18,
|
||||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f,
|
0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x43, 0x6f, 0x75,
|
||||||
0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x6e, 0x74, 0x32, 0xb1, 0x01, 0x0a, 0x10, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e,
|
||||||
|
0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x12, 0x58, 0x0a, 0x15, 0x43, 0x6f, 0x75, 0x6e, 0x74,
|
||||||
|
0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
|
||||||
|
0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x43, 0x6f,
|
||||||
|
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||||
|
0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x43, 0x6f, 0x6e,
|
||||||
|
0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
|
||||||
|
0x00, 0x12, 0x43, 0x0a, 0x0a, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12,
|
||||||
|
0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65,
|
||||||
|
0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||||
|
0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70,
|
||||||
|
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74,
|
||||||
|
0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -176,16 +282,20 @@ func file_stream_proto_rawDescGZIP() []byte {
|
|||||||
return file_stream_proto_rawDescData
|
return file_stream_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_stream_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
var file_stream_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||||
var file_stream_proto_goTypes = []any{
|
var file_stream_proto_goTypes = []any{
|
||||||
(*PushStreamRequest)(nil), // 0: proto.PushStreamRequest
|
(*CountConnectionRequest)(nil), // 0: proto.CountConnectionRequest
|
||||||
(*PushStreamResponse)(nil), // 1: proto.PushStreamResponse
|
(*CountConnectionResponse)(nil), // 1: proto.CountConnectionResponse
|
||||||
|
(*PushStreamRequest)(nil), // 2: proto.PushStreamRequest
|
||||||
|
(*PushStreamResponse)(nil), // 3: proto.PushStreamResponse
|
||||||
}
|
}
|
||||||
var file_stream_proto_depIdxs = []int32{
|
var file_stream_proto_depIdxs = []int32{
|
||||||
0, // 0: proto.StreamController.PushStream:input_type -> proto.PushStreamRequest
|
0, // 0: proto.StreamController.CountStreamConnection:input_type -> proto.CountConnectionRequest
|
||||||
1, // 1: proto.StreamController.PushStream:output_type -> proto.PushStreamResponse
|
2, // 1: proto.StreamController.PushStream:input_type -> proto.PushStreamRequest
|
||||||
1, // [1:2] is the sub-list for method output_type
|
1, // 2: proto.StreamController.CountStreamConnection:output_type -> proto.CountConnectionResponse
|
||||||
0, // [0:1] is the sub-list for method input_type
|
3, // 3: proto.StreamController.PushStream:output_type -> proto.PushStreamResponse
|
||||||
|
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 type_name
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
0, // [0:0] is the sub-list for extension extendee
|
||||||
0, // [0:0] is the sub-list for field type_name
|
0, // [0:0] is the sub-list for field type_name
|
||||||
@ -198,7 +308,7 @@ func file_stream_proto_init() {
|
|||||||
}
|
}
|
||||||
if !protoimpl.UnsafeEnabled {
|
if !protoimpl.UnsafeEnabled {
|
||||||
file_stream_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
file_stream_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||||
switch v := v.(*PushStreamRequest); i {
|
switch v := v.(*CountConnectionRequest); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
@ -210,6 +320,30 @@ func file_stream_proto_init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_stream_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
file_stream_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||||
|
switch v := v.(*CountConnectionResponse); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_stream_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||||
|
switch v := v.(*PushStreamRequest); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_stream_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||||
switch v := v.(*PushStreamResponse); i {
|
switch v := v.(*PushStreamResponse); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@ -228,7 +362,7 @@ func file_stream_proto_init() {
|
|||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_stream_proto_rawDesc,
|
RawDescriptor: file_stream_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 2,
|
NumMessages: 4,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
|
@ -5,9 +5,18 @@ option go_package = ".;proto";
|
|||||||
package proto;
|
package proto;
|
||||||
|
|
||||||
service StreamController {
|
service StreamController {
|
||||||
|
rpc CountStreamConnection(CountConnectionRequest) returns (CountConnectionResponse) {}
|
||||||
rpc PushStream(PushStreamRequest) returns (PushStreamResponse) {}
|
rpc PushStream(PushStreamRequest) returns (PushStreamResponse) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message CountConnectionRequest {
|
||||||
|
uint64 user_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CountConnectionResponse {
|
||||||
|
int64 count = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message PushStreamRequest {
|
message PushStreamRequest {
|
||||||
uint64 user_id = 1;
|
uint64 user_id = 1;
|
||||||
bytes body = 2;
|
bytes body = 2;
|
||||||
|
@ -19,13 +19,15 @@ import (
|
|||||||
const _ = grpc.SupportPackageIsVersion8
|
const _ = grpc.SupportPackageIsVersion8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
StreamController_PushStream_FullMethodName = "/proto.StreamController/PushStream"
|
StreamController_CountStreamConnection_FullMethodName = "/proto.StreamController/CountStreamConnection"
|
||||||
|
StreamController_PushStream_FullMethodName = "/proto.StreamController/PushStream"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StreamControllerClient is the client API for StreamController service.
|
// StreamControllerClient is the client API for StreamController 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.
|
// 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 StreamControllerClient interface {
|
type StreamControllerClient interface {
|
||||||
|
CountStreamConnection(ctx context.Context, in *CountConnectionRequest, opts ...grpc.CallOption) (*CountConnectionResponse, error)
|
||||||
PushStream(ctx context.Context, in *PushStreamRequest, opts ...grpc.CallOption) (*PushStreamResponse, error)
|
PushStream(ctx context.Context, in *PushStreamRequest, opts ...grpc.CallOption) (*PushStreamResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +39,16 @@ func NewStreamControllerClient(cc grpc.ClientConnInterface) StreamControllerClie
|
|||||||
return &streamControllerClient{cc}
|
return &streamControllerClient{cc}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *streamControllerClient) CountStreamConnection(ctx context.Context, in *CountConnectionRequest, opts ...grpc.CallOption) (*CountConnectionResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(CountConnectionResponse)
|
||||||
|
err := c.cc.Invoke(ctx, StreamController_CountStreamConnection_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *streamControllerClient) PushStream(ctx context.Context, in *PushStreamRequest, opts ...grpc.CallOption) (*PushStreamResponse, error) {
|
func (c *streamControllerClient) PushStream(ctx context.Context, in *PushStreamRequest, opts ...grpc.CallOption) (*PushStreamResponse, error) {
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
out := new(PushStreamResponse)
|
out := new(PushStreamResponse)
|
||||||
@ -51,6 +63,7 @@ func (c *streamControllerClient) PushStream(ctx context.Context, in *PushStreamR
|
|||||||
// All implementations must embed UnimplementedStreamControllerServer
|
// All implementations must embed UnimplementedStreamControllerServer
|
||||||
// for forward compatibility
|
// for forward compatibility
|
||||||
type StreamControllerServer interface {
|
type StreamControllerServer interface {
|
||||||
|
CountStreamConnection(context.Context, *CountConnectionRequest) (*CountConnectionResponse, error)
|
||||||
PushStream(context.Context, *PushStreamRequest) (*PushStreamResponse, error)
|
PushStream(context.Context, *PushStreamRequest) (*PushStreamResponse, error)
|
||||||
mustEmbedUnimplementedStreamControllerServer()
|
mustEmbedUnimplementedStreamControllerServer()
|
||||||
}
|
}
|
||||||
@ -59,6 +72,9 @@ type StreamControllerServer interface {
|
|||||||
type UnimplementedStreamControllerServer struct {
|
type UnimplementedStreamControllerServer struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (UnimplementedStreamControllerServer) CountStreamConnection(context.Context, *CountConnectionRequest) (*CountConnectionResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method CountStreamConnection not implemented")
|
||||||
|
}
|
||||||
func (UnimplementedStreamControllerServer) PushStream(context.Context, *PushStreamRequest) (*PushStreamResponse, error) {
|
func (UnimplementedStreamControllerServer) PushStream(context.Context, *PushStreamRequest) (*PushStreamResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method PushStream not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method PushStream not implemented")
|
||||||
}
|
}
|
||||||
@ -75,6 +91,24 @@ func RegisterStreamControllerServer(s grpc.ServiceRegistrar, srv StreamControlle
|
|||||||
s.RegisterService(&StreamController_ServiceDesc, srv)
|
s.RegisterService(&StreamController_ServiceDesc, srv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _StreamController_CountStreamConnection_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(CountConnectionRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(StreamControllerServer).CountStreamConnection(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: StreamController_CountStreamConnection_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(StreamControllerServer).CountStreamConnection(ctx, req.(*CountConnectionRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
func _StreamController_PushStream_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
func _StreamController_PushStream_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(PushStreamRequest)
|
in := new(PushStreamRequest)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
@ -100,6 +134,10 @@ var StreamController_ServiceDesc = grpc.ServiceDesc{
|
|||||||
ServiceName: "proto.StreamController",
|
ServiceName: "proto.StreamController",
|
||||||
HandlerType: (*StreamControllerServer)(nil),
|
HandlerType: (*StreamControllerServer)(nil),
|
||||||
Methods: []grpc.MethodDesc{
|
Methods: []grpc.MethodDesc{
|
||||||
|
{
|
||||||
|
MethodName: "CountStreamConnection",
|
||||||
|
Handler: _StreamController_CountStreamConnection_Handler,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
MethodName: "PushStream",
|
MethodName: "PushStream",
|
||||||
Handler: _StreamController_PushStream_Handler,
|
Handler: _StreamController_PushStream_Handler,
|
||||||
|
Loading…
Reference in New Issue
Block a user