add create channels to stream

This commit is contained in:
Asim Aslam
2021-11-03 16:03:20 +00:00
parent 784e1a71d3
commit 5ad499c8a0
6 changed files with 340 additions and 110 deletions

View File

@@ -32,6 +32,7 @@ type Metadata struct {
type Stream struct { type Stream struct {
Id string Id string
Description string
Messages []*Message Messages []*Message
Updated int64 Updated int64
} }
@@ -50,7 +51,7 @@ type Store struct {
mtx sync.RWMutex mtx sync.RWMutex
Streams *lru.Cache Streams *lru.Cache
streams map[string]int64 streams map[string]*Stream
metadatas map[string]*Metadata metadatas map[string]*Metadata
} }
@@ -63,14 +64,15 @@ func newStore() *Store {
Created: time.Now().UnixNano(), Created: time.Now().UnixNano(),
Streams: lru.New(maxStreams), Streams: lru.New(maxStreams),
Updates: make(chan *Message, 100), Updates: make(chan *Message, 100),
streams: make(map[string]int64), streams: make(map[string]*Stream),
metadatas: make(map[string]*Metadata), metadatas: make(map[string]*Metadata),
} }
} }
func newStream(id string) *Stream { func newStream(id, desc string) *Stream {
return &Stream{ return &Stream{
Id: id, Id: id,
Description: desc,
Updated: time.Now().UnixNano(), Updated: time.Now().UnixNano(),
} }
} }
@@ -140,6 +142,18 @@ func getMetadata(uri string) *Metadata {
return g return g
} }
func (c *Store) CreateStream(name, description string) {
c.mtx.Lock()
ch, ok := c.streams[name]
if ok {
ch.Description = description
} else {
ch = newStream(name, description)
}
c.streams[name] = ch
c.mtx.Unlock()
}
func (c *Store) Metadata(t *Message) { func (c *Store) Metadata(t *Message) {
parts := strings.Split(t.Text, " ") parts := strings.Split(t.Text, " ")
for _, part := range parts { for _, part := range parts {
@@ -154,7 +168,7 @@ func (c *Store) Metadata(t *Message) {
} }
} }
func (c *Store) List() map[string]int64 { func (c *Store) ListStreams() map[string]*Stream {
c.mtx.RLock() c.mtx.RLock()
streams := c.streams streams := c.streams
c.mtx.RUnlock() c.mtx.RUnlock()
@@ -170,7 +184,7 @@ func (c *Store) Save(message *Message) {
if obj, ok := c.Streams.Get(message.Stream); ok { if obj, ok := c.Streams.Get(message.Stream); ok {
stream = obj.(*Stream) stream = obj.(*Stream)
} else { } else {
stream = newStream(message.Stream) stream = newStream(message.Stream, "")
c.Streams.Add(message.Stream, stream) c.Streams.Add(message.Stream, stream)
} }
@@ -270,18 +284,24 @@ func (c *Store) Retrieve(message string, streem string, direction, last, limit i
func (c *Store) Run() { func (c *Store) Run() {
t1 := time.NewTicker(time.Hour) t1 := time.NewTicker(time.Hour)
t2 := time.NewTicker(time.Minute) t2 := time.NewTicker(time.Minute)
streams := make(map[string]int64) streams := make(map[string]*Stream)
for { for {
select { select {
case message := <-c.Updates: case message := <-c.Updates:
c.Save(message) c.Save(message)
streams[message.Stream] = time.Now().UnixNano() ch, ok := streams[message.Stream]
if !ok {
ch = newStream(message.Stream, "")
streams[message.Stream] = ch
}
ch.Updated = time.Now().UnixNano()
streams[message.Stream] = ch
go c.Metadata(message) go c.Metadata(message)
case <-t1.C: case <-t1.C:
now := time.Now().UnixNano() now := time.Now().UnixNano()
for stream, u := range streams { for stream, ch := range streams {
if d := now - u; d > streamTTL { if d := now - ch.Updated; d > streamTTL {
c.Streams.Remove(stream) c.Streams.Remove(stream)
delete(streams, stream) delete(streams, stream)
} }
@@ -301,8 +321,12 @@ func (c *Store) Run() {
} }
} }
func ListChannels() map[string]int64 { func CreateChannel(name, description string) {
return C.List() C.CreateStream(name, description)
}
func ListChannels() map[string]*Stream {
return C.ListStreams()
} }
func ListMessages(channel string, limit int64) []*Message { func ListMessages(channel string, limit int64) []*Message {

View File

@@ -1,5 +1,15 @@
{ {
"createChannel": [{
"title": "Create Channel",
"description": "Create a channel with name and description",
"run_check": true,
"request": {
"name": "general",
"description": "The channel for all things"
},
"response": {}
}],
"sendMessage": [{ "sendMessage": [{
"title": "Send message", "title": "Send message",
"description": "Send a message to a channel", "description": "Send a message to a channel",
@@ -38,6 +48,7 @@
"channels": [ "channels": [
{ {
"name": "general", "name": "general",
"description": "The channel for all things",
"last_active": "2021-11-03T14:35:07.594972213Z" "last_active": "2021-11-03T14:35:07.594972213Z"
} }
] ]

View File

@@ -19,6 +19,22 @@ func New() *Stream {
return &Stream{} return &Stream{}
} }
func (s *Stream) CreateChannel(ctx context.Context, req *pb.CreateChannelRequest, rsp *pb.CreateChannelResponse) error {
// get the tenant
id, ok := tenant.FromContext(ctx)
if !ok {
id = "default"
}
if len(req.Name) == 0 {
return errors.BadRequest("stream.createchannel", "name is blank")
}
domain.CreateChannel(path.Join(id, req.Name), req.Description)
return nil
}
func (s *Stream) SendMessage(ctx context.Context, req *pb.SendMessageRequest, rsp *pb.SendMessageResponse) error { func (s *Stream) SendMessage(ctx context.Context, req *pb.SendMessageRequest, rsp *pb.SendMessageResponse) error {
if len(req.Channel) == 0 { if len(req.Channel) == 0 {
return errors.BadRequest("stream.sendmessage", "channel is blank") return errors.BadRequest("stream.sendmessage", "channel is blank")
@@ -93,16 +109,17 @@ func (s *Stream) ListChannels(ctx context.Context, req *pb.ListChannelsRequest,
id = "default" id = "default"
} }
for channel, active := range domain.ListChannels() { for _, channel := range domain.ListChannels() {
if !strings.HasPrefix(channel, id+"/") { if !strings.HasPrefix(channel.Id, id+"/") {
continue continue
} }
channel = strings.TrimPrefix(channel, id+"/") name := strings.TrimPrefix(channel.Id, id+"/")
rsp.Channels = append(rsp.Channels, &pb.Channel{ rsp.Channels = append(rsp.Channels, &pb.Channel{
Name: channel, Name: name,
LastActive: time.Unix(0, active).Format(time.RFC3339Nano), Description: channel.Description,
LastActive: time.Unix(0, channel.Updated).Format(time.RFC3339Nano),
}) })
} }

View File

@@ -111,8 +111,10 @@ type Channel struct {
// name of the channel // name of the channel
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// description for the channel
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
// last activity time // last activity time
LastActive string `protobuf:"bytes,2,opt,name=last_active,json=lastActive,proto3" json:"last_active,omitempty"` LastActive string `protobuf:"bytes,3,opt,name=last_active,json=lastActive,proto3" json:"last_active,omitempty"`
} }
func (x *Channel) Reset() { func (x *Channel) Reset() {
@@ -154,6 +156,13 @@ func (x *Channel) GetName() string {
return "" return ""
} }
func (x *Channel) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
func (x *Channel) GetLastActive() string { func (x *Channel) GetLastActive() string {
if x != nil { if x != nil {
return x.LastActive return x.LastActive
@@ -161,7 +170,104 @@ func (x *Channel) GetLastActive() string {
return "" return ""
} }
// SendMessage a message to the stream. // Create a channel with a given name and description. Channels are created automatically but
// this allows you to specify a description that's persisted for the lifetime of the channel.
type CreateChannelRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// name of the channel
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// description for the channel
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
}
func (x *CreateChannelRequest) Reset() {
*x = CreateChannelRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_stream_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateChannelRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateChannelRequest) ProtoMessage() {}
func (x *CreateChannelRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_stream_proto_msgTypes[2]
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 CreateChannelRequest.ProtoReflect.Descriptor instead.
func (*CreateChannelRequest) Descriptor() ([]byte, []int) {
return file_proto_stream_proto_rawDescGZIP(), []int{2}
}
func (x *CreateChannelRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *CreateChannelRequest) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
type CreateChannelResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *CreateChannelResponse) Reset() {
*x = CreateChannelResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_stream_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateChannelResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateChannelResponse) ProtoMessage() {}
func (x *CreateChannelResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_stream_proto_msgTypes[3]
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 CreateChannelResponse.ProtoReflect.Descriptor instead.
func (*CreateChannelResponse) Descriptor() ([]byte, []int) {
return file_proto_stream_proto_rawDescGZIP(), []int{3}
}
// Send a message to the stream.
type SendMessageRequest struct { type SendMessageRequest struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@@ -176,7 +282,7 @@ type SendMessageRequest struct {
func (x *SendMessageRequest) Reset() { func (x *SendMessageRequest) Reset() {
*x = SendMessageRequest{} *x = SendMessageRequest{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_proto_stream_proto_msgTypes[2] mi := &file_proto_stream_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -189,7 +295,7 @@ func (x *SendMessageRequest) String() string {
func (*SendMessageRequest) ProtoMessage() {} func (*SendMessageRequest) ProtoMessage() {}
func (x *SendMessageRequest) ProtoReflect() protoreflect.Message { func (x *SendMessageRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_stream_proto_msgTypes[2] mi := &file_proto_stream_proto_msgTypes[4]
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 {
@@ -202,7 +308,7 @@ func (x *SendMessageRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use SendMessageRequest.ProtoReflect.Descriptor instead. // Deprecated: Use SendMessageRequest.ProtoReflect.Descriptor instead.
func (*SendMessageRequest) Descriptor() ([]byte, []int) { func (*SendMessageRequest) Descriptor() ([]byte, []int) {
return file_proto_stream_proto_rawDescGZIP(), []int{2} return file_proto_stream_proto_rawDescGZIP(), []int{4}
} }
func (x *SendMessageRequest) GetChannel() string { func (x *SendMessageRequest) GetChannel() string {
@@ -228,7 +334,7 @@ type SendMessageResponse struct {
func (x *SendMessageResponse) Reset() { func (x *SendMessageResponse) Reset() {
*x = SendMessageResponse{} *x = SendMessageResponse{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_proto_stream_proto_msgTypes[3] mi := &file_proto_stream_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -241,7 +347,7 @@ func (x *SendMessageResponse) String() string {
func (*SendMessageResponse) ProtoMessage() {} func (*SendMessageResponse) ProtoMessage() {}
func (x *SendMessageResponse) ProtoReflect() protoreflect.Message { func (x *SendMessageResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_stream_proto_msgTypes[3] mi := &file_proto_stream_proto_msgTypes[5]
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 {
@@ -254,7 +360,7 @@ func (x *SendMessageResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use SendMessageResponse.ProtoReflect.Descriptor instead. // Deprecated: Use SendMessageResponse.ProtoReflect.Descriptor instead.
func (*SendMessageResponse) Descriptor() ([]byte, []int) { func (*SendMessageResponse) Descriptor() ([]byte, []int) {
return file_proto_stream_proto_rawDescGZIP(), []int{3} return file_proto_stream_proto_rawDescGZIP(), []int{5}
} }
// List all the active channels // List all the active channels
@@ -267,7 +373,7 @@ type ListChannelsRequest struct {
func (x *ListChannelsRequest) Reset() { func (x *ListChannelsRequest) Reset() {
*x = ListChannelsRequest{} *x = ListChannelsRequest{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_proto_stream_proto_msgTypes[4] mi := &file_proto_stream_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -280,7 +386,7 @@ func (x *ListChannelsRequest) String() string {
func (*ListChannelsRequest) ProtoMessage() {} func (*ListChannelsRequest) ProtoMessage() {}
func (x *ListChannelsRequest) ProtoReflect() protoreflect.Message { func (x *ListChannelsRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_stream_proto_msgTypes[4] mi := &file_proto_stream_proto_msgTypes[6]
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 {
@@ -293,7 +399,7 @@ func (x *ListChannelsRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use ListChannelsRequest.ProtoReflect.Descriptor instead. // Deprecated: Use ListChannelsRequest.ProtoReflect.Descriptor instead.
func (*ListChannelsRequest) Descriptor() ([]byte, []int) { func (*ListChannelsRequest) Descriptor() ([]byte, []int) {
return file_proto_stream_proto_rawDescGZIP(), []int{4} return file_proto_stream_proto_rawDescGZIP(), []int{6}
} }
type ListChannelsResponse struct { type ListChannelsResponse struct {
@@ -307,7 +413,7 @@ type ListChannelsResponse struct {
func (x *ListChannelsResponse) Reset() { func (x *ListChannelsResponse) Reset() {
*x = ListChannelsResponse{} *x = ListChannelsResponse{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_proto_stream_proto_msgTypes[5] mi := &file_proto_stream_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -320,7 +426,7 @@ func (x *ListChannelsResponse) String() string {
func (*ListChannelsResponse) ProtoMessage() {} func (*ListChannelsResponse) ProtoMessage() {}
func (x *ListChannelsResponse) ProtoReflect() protoreflect.Message { func (x *ListChannelsResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_stream_proto_msgTypes[5] mi := &file_proto_stream_proto_msgTypes[7]
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 {
@@ -333,7 +439,7 @@ func (x *ListChannelsResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use ListChannelsResponse.ProtoReflect.Descriptor instead. // Deprecated: Use ListChannelsResponse.ProtoReflect.Descriptor instead.
func (*ListChannelsResponse) Descriptor() ([]byte, []int) { func (*ListChannelsResponse) Descriptor() ([]byte, []int) {
return file_proto_stream_proto_rawDescGZIP(), []int{5} return file_proto_stream_proto_rawDescGZIP(), []int{7}
} }
func (x *ListChannelsResponse) GetChannels() []*Channel { func (x *ListChannelsResponse) GetChannels() []*Channel {
@@ -358,7 +464,7 @@ type ListMessagesRequest struct {
func (x *ListMessagesRequest) Reset() { func (x *ListMessagesRequest) Reset() {
*x = ListMessagesRequest{} *x = ListMessagesRequest{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_proto_stream_proto_msgTypes[6] mi := &file_proto_stream_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -371,7 +477,7 @@ func (x *ListMessagesRequest) String() string {
func (*ListMessagesRequest) ProtoMessage() {} func (*ListMessagesRequest) ProtoMessage() {}
func (x *ListMessagesRequest) ProtoReflect() protoreflect.Message { func (x *ListMessagesRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_stream_proto_msgTypes[6] mi := &file_proto_stream_proto_msgTypes[8]
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 {
@@ -384,7 +490,7 @@ func (x *ListMessagesRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use ListMessagesRequest.ProtoReflect.Descriptor instead. // Deprecated: Use ListMessagesRequest.ProtoReflect.Descriptor instead.
func (*ListMessagesRequest) Descriptor() ([]byte, []int) { func (*ListMessagesRequest) Descriptor() ([]byte, []int) {
return file_proto_stream_proto_rawDescGZIP(), []int{6} return file_proto_stream_proto_rawDescGZIP(), []int{8}
} }
func (x *ListMessagesRequest) GetChannel() string { func (x *ListMessagesRequest) GetChannel() string {
@@ -408,14 +514,14 @@ type ListMessagesResponse struct {
// The channel subscribed to // The channel subscribed to
Channel string `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"` Channel string `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"`
// Messages are returned in reverse order; latest first // Messages are chronological order
Messages []*Message `protobuf:"bytes,2,rep,name=messages,proto3" json:"messages,omitempty"` Messages []*Message `protobuf:"bytes,2,rep,name=messages,proto3" json:"messages,omitempty"`
} }
func (x *ListMessagesResponse) Reset() { func (x *ListMessagesResponse) Reset() {
*x = ListMessagesResponse{} *x = ListMessagesResponse{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_proto_stream_proto_msgTypes[7] mi := &file_proto_stream_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -428,7 +534,7 @@ func (x *ListMessagesResponse) String() string {
func (*ListMessagesResponse) ProtoMessage() {} func (*ListMessagesResponse) ProtoMessage() {}
func (x *ListMessagesResponse) ProtoReflect() protoreflect.Message { func (x *ListMessagesResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_stream_proto_msgTypes[7] mi := &file_proto_stream_proto_msgTypes[9]
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 {
@@ -441,7 +547,7 @@ func (x *ListMessagesResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use ListMessagesResponse.ProtoReflect.Descriptor instead. // Deprecated: Use ListMessagesResponse.ProtoReflect.Descriptor instead.
func (*ListMessagesResponse) Descriptor() ([]byte, []int) { func (*ListMessagesResponse) Descriptor() ([]byte, []int) {
return file_proto_stream_proto_rawDescGZIP(), []int{7} return file_proto_stream_proto_rawDescGZIP(), []int{9}
} }
func (x *ListMessagesResponse) GetChannel() string { func (x *ListMessagesResponse) GetChannel() string {
@@ -476,50 +582,63 @@ var file_proto_stream_proto_rawDesc = []byte{
0x3b, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x3b, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79,
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b,
0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3e, 0x0a, 0x07, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x60, 0x0a, 0x07,
0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64,
0x61, 0x73, 0x74, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0a, 0x6c, 0x61, 0x73, 0x74, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x22, 0x42, 0x0a, 0x12, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a,
0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x03, 0x20, 0x01,
0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x28, 0x09, 0x52, 0x0a, 0x6c, 0x61, 0x73, 0x74, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x22, 0x4c,
0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52,
0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,
0x22, 0x15, 0x0a, 0x13, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x15, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x43, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x17, 0x0a, 0x15,
0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x73, 0x52, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x73,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x42, 0x0a, 0x12, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x73,
0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63,
0x6d, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x08, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x68,
0x65, 0x6c, 0x73, 0x22, 0x45, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20,
0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x68, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x65, 0x6e,
0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x68, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x22, 0x15, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x73,
0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x5d, 0x0a, 0x14, 0x4c, 0x69, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x43, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x43,
0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x2b, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x6e,
0x65, 0x6c, 0x52, 0x08, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x73, 0x22, 0x45, 0x0a, 0x13,
0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x14, 0x0a,
0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69,
0x6d, 0x69, 0x74, 0x22, 0x5d, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63,
0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x68,
0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x2b, 0x0a, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d,
0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x73, 0x32, 0xbc, 0x02, 0x0a, 0x06, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x4e, 0x0a,
0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x1c,
0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x68,
0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x73,
0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e,
0x6e, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x48, 0x0a,
0x0b, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x2e, 0x73,
0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61,
0x6d, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x4d,
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x1b, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d,
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x4c, 0x69,
0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x68, 0x61, 0x6e,
0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x2b, 0x0a, 0x08, 0x6e, 0x65, 0x6c, 0x73, 0x12, 0x1b, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x4c, 0x69,
0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x73, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x74, 0x1a, 0x1c, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43,
0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x32, 0xec, 0x01, 0x0a, 0x06, 0x53, 0x74, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x72, 0x65, 0x61, 0x6d, 0x12, 0x48, 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x00, 0x42, 0x10, 0x5a, 0x0e, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x73, 0x74, 0x72,
0x61, 0x67, 0x65, 0x12, 0x1a, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x53, 0x65, 0x6e, 0x65, 0x61, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x1b, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4b,
0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x1b,
0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x73, 0x74,
0x72, 0x65, 0x61, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x0c, 0x4c,
0x69, 0x73, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x73, 0x12, 0x1b, 0x2e, 0x73, 0x74,
0x72, 0x65, 0x61, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c,
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61,
0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x73, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x10, 0x5a, 0x0e, 0x2e, 0x2f, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x3b, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
} }
var ( var (
@@ -534,33 +653,37 @@ func file_proto_stream_proto_rawDescGZIP() []byte {
return file_proto_stream_proto_rawDescData return file_proto_stream_proto_rawDescData
} }
var file_proto_stream_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_proto_stream_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_proto_stream_proto_goTypes = []interface{}{ var file_proto_stream_proto_goTypes = []interface{}{
(*Message)(nil), // 0: stream.Message (*Message)(nil), // 0: stream.Message
(*Channel)(nil), // 1: stream.Channel (*Channel)(nil), // 1: stream.Channel
(*SendMessageRequest)(nil), // 2: stream.SendMessageRequest (*CreateChannelRequest)(nil), // 2: stream.CreateChannelRequest
(*SendMessageResponse)(nil), // 3: stream.SendMessageResponse (*CreateChannelResponse)(nil), // 3: stream.CreateChannelResponse
(*ListChannelsRequest)(nil), // 4: stream.ListChannelsRequest (*SendMessageRequest)(nil), // 4: stream.SendMessageRequest
(*ListChannelsResponse)(nil), // 5: stream.ListChannelsResponse (*SendMessageResponse)(nil), // 5: stream.SendMessageResponse
(*ListMessagesRequest)(nil), // 6: stream.ListMessagesRequest (*ListChannelsRequest)(nil), // 6: stream.ListChannelsRequest
(*ListMessagesResponse)(nil), // 7: stream.ListMessagesResponse (*ListChannelsResponse)(nil), // 7: stream.ListChannelsResponse
nil, // 8: stream.Message.MetadataEntry (*ListMessagesRequest)(nil), // 8: stream.ListMessagesRequest
(*ListMessagesResponse)(nil), // 9: stream.ListMessagesResponse
nil, // 10: stream.Message.MetadataEntry
} }
var file_proto_stream_proto_depIdxs = []int32{ var file_proto_stream_proto_depIdxs = []int32{
8, // 0: stream.Message.metadata:type_name -> stream.Message.MetadataEntry 10, // 0: stream.Message.metadata:type_name -> stream.Message.MetadataEntry
1, // 1: stream.ListChannelsResponse.channels:type_name -> stream.Channel 1, // 1: stream.ListChannelsResponse.channels:type_name -> stream.Channel
0, // 2: stream.ListMessagesResponse.messages:type_name -> stream.Message 0, // 2: stream.ListMessagesResponse.messages:type_name -> stream.Message
2, // 3: stream.Stream.SendMessage:input_type -> stream.SendMessageRequest 2, // 3: stream.Stream.CreateChannel:input_type -> stream.CreateChannelRequest
6, // 4: stream.Stream.ListMessages:input_type -> stream.ListMessagesRequest 4, // 4: stream.Stream.SendMessage:input_type -> stream.SendMessageRequest
4, // 5: stream.Stream.ListChannels:input_type -> stream.ListChannelsRequest 8, // 5: stream.Stream.ListMessages:input_type -> stream.ListMessagesRequest
3, // 6: stream.Stream.SendMessage:output_type -> stream.SendMessageResponse 6, // 6: stream.Stream.ListChannels:input_type -> stream.ListChannelsRequest
7, // 7: stream.Stream.ListMessages:output_type -> stream.ListMessagesResponse 3, // 7: stream.Stream.CreateChannel:output_type -> stream.CreateChannelResponse
5, // 8: stream.Stream.ListChannels:output_type -> stream.ListChannelsResponse 5, // 8: stream.Stream.SendMessage:output_type -> stream.SendMessageResponse
6, // [6:9] is the sub-list for method output_type 9, // 9: stream.Stream.ListMessages:output_type -> stream.ListMessagesResponse
3, // [3:6] is the sub-list for method input_type 7, // 10: stream.Stream.ListChannels:output_type -> stream.ListChannelsResponse
3, // [3:3] is the sub-list for extension type_name 7, // [7:11] is the sub-list for method output_type
3, // [3:3] is the sub-list for extension extendee 3, // [3:7] is the sub-list for method input_type
0, // [0:3] is the sub-list for field type_name 3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
} }
func init() { file_proto_stream_proto_init() } func init() { file_proto_stream_proto_init() }
@@ -594,7 +717,7 @@ func file_proto_stream_proto_init() {
} }
} }
file_proto_stream_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { file_proto_stream_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SendMessageRequest); i { switch v := v.(*CreateChannelRequest); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@@ -606,7 +729,7 @@ func file_proto_stream_proto_init() {
} }
} }
file_proto_stream_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { file_proto_stream_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SendMessageResponse); i { switch v := v.(*CreateChannelResponse); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@@ -618,7 +741,7 @@ func file_proto_stream_proto_init() {
} }
} }
file_proto_stream_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { file_proto_stream_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListChannelsRequest); i { switch v := v.(*SendMessageRequest); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@@ -630,7 +753,7 @@ func file_proto_stream_proto_init() {
} }
} }
file_proto_stream_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { file_proto_stream_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListChannelsResponse); i { switch v := v.(*SendMessageResponse); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@@ -642,7 +765,7 @@ func file_proto_stream_proto_init() {
} }
} }
file_proto_stream_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { file_proto_stream_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListMessagesRequest); i { switch v := v.(*ListChannelsRequest); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@@ -654,6 +777,30 @@ func file_proto_stream_proto_init() {
} }
} }
file_proto_stream_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { file_proto_stream_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListChannelsResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_stream_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListMessagesRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_stream_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListMessagesResponse); i { switch v := v.(*ListMessagesResponse); i {
case 0: case 0:
return &v.state return &v.state
@@ -672,7 +819,7 @@ func file_proto_stream_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_stream_proto_rawDesc, RawDescriptor: file_proto_stream_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 9, NumMessages: 11,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },

View File

@@ -42,6 +42,7 @@ func NewStreamEndpoints() []*api.Endpoint {
// Client API for Stream service // Client API for Stream service
type StreamService interface { type StreamService interface {
CreateChannel(ctx context.Context, in *CreateChannelRequest, opts ...client.CallOption) (*CreateChannelResponse, error)
SendMessage(ctx context.Context, in *SendMessageRequest, opts ...client.CallOption) (*SendMessageResponse, error) SendMessage(ctx context.Context, in *SendMessageRequest, opts ...client.CallOption) (*SendMessageResponse, error)
ListMessages(ctx context.Context, in *ListMessagesRequest, opts ...client.CallOption) (*ListMessagesResponse, error) ListMessages(ctx context.Context, in *ListMessagesRequest, opts ...client.CallOption) (*ListMessagesResponse, error)
ListChannels(ctx context.Context, in *ListChannelsRequest, opts ...client.CallOption) (*ListChannelsResponse, error) ListChannels(ctx context.Context, in *ListChannelsRequest, opts ...client.CallOption) (*ListChannelsResponse, error)
@@ -59,6 +60,16 @@ func NewStreamService(name string, c client.Client) StreamService {
} }
} }
func (c *streamService) CreateChannel(ctx context.Context, in *CreateChannelRequest, opts ...client.CallOption) (*CreateChannelResponse, error) {
req := c.c.NewRequest(c.name, "Stream.CreateChannel", in)
out := new(CreateChannelResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *streamService) SendMessage(ctx context.Context, in *SendMessageRequest, opts ...client.CallOption) (*SendMessageResponse, error) { func (c *streamService) SendMessage(ctx context.Context, in *SendMessageRequest, opts ...client.CallOption) (*SendMessageResponse, error) {
req := c.c.NewRequest(c.name, "Stream.SendMessage", in) req := c.c.NewRequest(c.name, "Stream.SendMessage", in)
out := new(SendMessageResponse) out := new(SendMessageResponse)
@@ -92,6 +103,7 @@ func (c *streamService) ListChannels(ctx context.Context, in *ListChannelsReques
// Server API for Stream service // Server API for Stream service
type StreamHandler interface { type StreamHandler interface {
CreateChannel(context.Context, *CreateChannelRequest, *CreateChannelResponse) error
SendMessage(context.Context, *SendMessageRequest, *SendMessageResponse) error SendMessage(context.Context, *SendMessageRequest, *SendMessageResponse) error
ListMessages(context.Context, *ListMessagesRequest, *ListMessagesResponse) error ListMessages(context.Context, *ListMessagesRequest, *ListMessagesResponse) error
ListChannels(context.Context, *ListChannelsRequest, *ListChannelsResponse) error ListChannels(context.Context, *ListChannelsRequest, *ListChannelsResponse) error
@@ -99,6 +111,7 @@ type StreamHandler interface {
func RegisterStreamHandler(s server.Server, hdlr StreamHandler, opts ...server.HandlerOption) error { func RegisterStreamHandler(s server.Server, hdlr StreamHandler, opts ...server.HandlerOption) error {
type stream interface { type stream interface {
CreateChannel(ctx context.Context, in *CreateChannelRequest, out *CreateChannelResponse) error
SendMessage(ctx context.Context, in *SendMessageRequest, out *SendMessageResponse) error SendMessage(ctx context.Context, in *SendMessageRequest, out *SendMessageResponse) error
ListMessages(ctx context.Context, in *ListMessagesRequest, out *ListMessagesResponse) error ListMessages(ctx context.Context, in *ListMessagesRequest, out *ListMessagesResponse) error
ListChannels(ctx context.Context, in *ListChannelsRequest, out *ListChannelsResponse) error ListChannels(ctx context.Context, in *ListChannelsRequest, out *ListChannelsResponse) error
@@ -114,6 +127,10 @@ type streamHandler struct {
StreamHandler StreamHandler
} }
func (h *streamHandler) CreateChannel(ctx context.Context, in *CreateChannelRequest, out *CreateChannelResponse) error {
return h.StreamHandler.CreateChannel(ctx, in, out)
}
func (h *streamHandler) SendMessage(ctx context.Context, in *SendMessageRequest, out *SendMessageResponse) error { func (h *streamHandler) SendMessage(ctx context.Context, in *SendMessageRequest, out *SendMessageResponse) error {
return h.StreamHandler.SendMessage(ctx, in, out) return h.StreamHandler.SendMessage(ctx, in, out)
} }

View File

@@ -5,6 +5,7 @@ package stream;
option go_package = "./proto;stream"; option go_package = "./proto;stream";
service Stream { service Stream {
rpc CreateChannel(CreateChannelRequest) returns (CreateChannelResponse) {}
rpc SendMessage(SendMessageRequest) returns (SendMessageResponse) {} rpc SendMessage(SendMessageRequest) returns (SendMessageResponse) {}
rpc ListMessages(ListMessagesRequest) returns (ListMessagesResponse) {} rpc ListMessages(ListMessagesRequest) returns (ListMessagesResponse) {}
rpc ListChannels(ListChannelsRequest) returns (ListChannelsResponse) {} rpc ListChannels(ListChannelsRequest) returns (ListChannelsResponse) {}
@@ -26,10 +27,23 @@ message Message {
message Channel { message Channel {
// name of the channel // name of the channel
string name = 1; string name = 1;
// description for the channel
string description = 2;
// last activity time // last activity time
string last_active = 2; string last_active = 3;
} }
// Create a channel with a given name and description. Channels are created automatically but
// this allows you to specify a description that's persisted for the lifetime of the channel.
message CreateChannelRequest {
// name of the channel
string name = 1;
// description for the channel
string description = 2;
}
message CreateChannelResponse {}
// Send a message to the stream. // Send a message to the stream.
message SendMessageRequest { message SendMessageRequest {
// The channel to send to // The channel to send to