From 6abcf9668d7524f4f9f5b27a1e36ff6270ad46ab Mon Sep 17 00:00:00 2001 From: Aaron Sutula Date: Mon, 16 Dec 2019 21:49:58 -0700 Subject: [PATCH] Implement listener client and test Signed-off-by: Aaron Sutula --- api/client/client.go | 74 +++++++--- api/client/client_test.go | 41 ++++-- api/pb/api.pb.go | 299 +++++++++++++++++++++++++++----------- api/pb/api.proto | 4 +- api/service.go | 52 +++++-- 5 files changed, 338 insertions(+), 132 deletions(-) diff --git a/api/client/client.go b/api/client/client.go index 8565bc77..fdd52ff1 100644 --- a/api/client/client.go +++ b/api/client/client.go @@ -9,6 +9,7 @@ import ( "github.com/mr-tron/base58" ma "github.com/multiformats/go-multiaddr" "github.com/textileio/go-textile-core/crypto/symmetric" + "github.com/textileio/go-textile-core/store" pb "github.com/textileio/go-textile-threads/api/pb" es "github.com/textileio/go-textile-threads/eventstore" "google.golang.org/grpc" @@ -26,8 +27,8 @@ type Client struct { // ListenEvent is used to send data or error values for Listen type ListenEvent struct { - data []byte - err error + action es.Action + err error } // NewClient starts the client @@ -231,22 +232,45 @@ func (c *Client) WriteTransaction(storeID, modelName string) (*WriteTransaction, return &WriteTransaction{client: client, storeID: storeID, modelName: modelName}, nil } -// Listen provides an update whenever the specified model is updated -func (c *Client) Listen(storeID, modelName, entityID string) (<-chan ListenEvent, func()) { +// Listen provides an update whenever the specified store, model type, or model instance is updated +func (c *Client) Listen(storeID string, listenOptions ...es.ListenOption) (<-chan ListenEvent, func(), error) { channel := make(chan ListenEvent) ctx, cancel := context.WithCancel(c.ctx) - go func() { - defer close(channel) - req := &pb.ListenRequest{ - StoreID: storeID, - ModelName: modelName, - EntityID: entityID, + filters := make([]*pb.ListenRequest_Filter, len(listenOptions)) + for i, listenOption := range listenOptions { + var action pb.ListenRequest_Filter_Action + switch listenOption.Type { + case es.ListenAll: + action = pb.ListenRequest_Filter_ALL + case es.ListenCreate: + action = pb.ListenRequest_Filter_CREATE + case es.ListenDelete: + action = pb.ListenRequest_Filter_DELETE + case es.ListenSave: + action = pb.ListenRequest_Filter_SAVE + default: + cancel() + return nil, nil, fmt.Errorf("unknown ListenOption.Type %v", listenOption.Type) } - stream, err := c.client.Listen(ctx, req) - if err != nil { - channel <- ListenEvent{err: err} - return + filters[i] = &pb.ListenRequest_Filter{ + ModelName: listenOption.Model, + EntityID: listenOption.ID.String(), + Action: action, } + } + req := &pb.ListenRequest{ + StoreID: storeID, + Filters: filters, + } + stream, err := c.client.Listen(ctx, req) + if err != nil { + cancel() + return nil, nil, err + } + go func() { + defer close(channel) + + L: for { event, err := stream.Recv() if err != nil { @@ -256,11 +280,27 @@ func (c *Client) Listen(storeID, modelName, entityID string) (<-chan ListenEvent } break } - bytes := []byte(event.GetEntity()) - channel <- ListenEvent{data: bytes} + var actionType es.ActionType + switch event.GetAction() { + case pb.ListenReply_CREATE: + actionType = es.ActionCreate + case pb.ListenReply_DELETE: + actionType = es.ActionDelete + case pb.ListenReply_SAVE: + actionType = es.ActionSave + default: + channel <- ListenEvent{err: fmt.Errorf("unknown listen reply action %v", event.GetAction())} + break L + } + action := es.Action{ + Model: event.GetModelName(), + ID: store.EntityID(event.GetEntityID()), + Type: actionType, + } + channel <- ListenEvent{action: action} } }() - return channel, cancel + return channel, cancel, nil } func processFindReply(reply *pb.ModelFindReply, dummySlice interface{}) (interface{}, error) { diff --git a/api/client/client_test.go b/api/client/client_test.go index 622aabf3..ef938241 100644 --- a/api/client/client_test.go +++ b/api/client/client_test.go @@ -2,7 +2,6 @@ package client import ( "context" - "encoding/json" "fmt" "io/ioutil" "os" @@ -11,6 +10,7 @@ import ( "time" ma "github.com/multiformats/go-multiaddr" + "github.com/textileio/go-textile-core/store" "github.com/textileio/go-textile-threads/api" es "github.com/textileio/go-textile-threads/eventstore" "github.com/textileio/go-textile-threads/util" @@ -395,8 +395,15 @@ func TestListen(t *testing.T) { err = client.ModelCreate(storeID, modelName, person) checkErr(t, err) - channel, discard := client.Listen(storeID, modelName, person.ID) + opt := es.ListenOption{ + Model: modelName, + ID: store.EntityID(person.ID), + } + channel, discard, err := client.Listen(storeID, opt) defer discard() + if err != nil { + t.Fatalf("failed to call listen: %v", err) + } go func() { time.Sleep(1 * time.Second) @@ -413,12 +420,15 @@ func TestListen(t *testing.T) { if val.err != nil { t.Fatalf("failed to receive first listen result: %v", val.err) } - p := &Person{} - if err := json.Unmarshal(val.data, p); err != nil { - t.Fatalf("failed to unmarshal listen result: %v", err) - } - if p.Age != 30 { - t.Fatalf("expected listen result age = 30 but got: %v", p.Age) + // p := &Person{} + // if err := json.Unmarshal(val.data, p); err != nil { + // t.Fatalf("failed to unmarshal listen result: %v", err) + // } + // if p.Age != 30 { + // t.Fatalf("expected listen result age = 30 but got: %v", p.Age) + // } + if val.action.ID.String() != person.ID { + t.Fatalf("expected listen result id = %v but got: %v", person.ID, val.action.ID.String()) } } @@ -429,12 +439,15 @@ func TestListen(t *testing.T) { if val.err != nil { t.Fatalf("failed to receive second listen result: %v", val.err) } - p := &Person{} - if err := json.Unmarshal(val.data, p); err != nil { - t.Fatalf("failed to unmarshal listen result: %v", err) - } - if p.Age != 40 { - t.Fatalf("expected listen result age = 40 but got: %v", p.Age) + // p := &Person{} + // if err := json.Unmarshal(val.data, p); err != nil { + // t.Fatalf("failed to unmarshal listen result: %v", err) + // } + // if p.Age != 40 { + // t.Fatalf("expected listen result age = 40 but got: %v", p.Age) + // } + if val.action.ID.String() != person.ID { + t.Fatalf("expected listen result id = %v but got: %v", person.ID, val.action.ID.String()) } } } diff --git a/api/pb/api.pb.go b/api/pb/api.pb.go index e6802a9a..e3399a1b 100644 --- a/api/pb/api.pb.go +++ b/api/pb/api.pb.go @@ -24,6 +24,65 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +type ListenRequest_Filter_Action int32 + +const ( + ListenRequest_Filter_ALL ListenRequest_Filter_Action = 0 + ListenRequest_Filter_CREATE ListenRequest_Filter_Action = 1 + ListenRequest_Filter_SAVE ListenRequest_Filter_Action = 2 + ListenRequest_Filter_DELETE ListenRequest_Filter_Action = 3 +) + +var ListenRequest_Filter_Action_name = map[int32]string{ + 0: "ALL", + 1: "CREATE", + 2: "SAVE", + 3: "DELETE", +} + +var ListenRequest_Filter_Action_value = map[string]int32{ + "ALL": 0, + "CREATE": 1, + "SAVE": 2, + "DELETE": 3, +} + +func (x ListenRequest_Filter_Action) String() string { + return proto.EnumName(ListenRequest_Filter_Action_name, int32(x)) +} + +func (ListenRequest_Filter_Action) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_00212fb1f9d3bf1c, []int{27, 0, 0} +} + +type ListenReply_Action int32 + +const ( + ListenReply_CREATE ListenReply_Action = 0 + ListenReply_SAVE ListenReply_Action = 1 + ListenReply_DELETE ListenReply_Action = 2 +) + +var ListenReply_Action_name = map[int32]string{ + 0: "CREATE", + 1: "SAVE", + 2: "DELETE", +} + +var ListenReply_Action_value = map[string]int32{ + "CREATE": 0, + "SAVE": 1, + "DELETE": 2, +} + +func (x ListenReply_Action) String() string { + return proto.EnumName(ListenReply_Action_name, int32(x)) +} + +func (ListenReply_Action) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_00212fb1f9d3bf1c, []int{28, 0} +} + type NewStoreRequest struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -1534,12 +1593,11 @@ func (*WriteTransactionReply) XXX_OneofWrappers() []interface{} { } type ListenRequest struct { - StoreID string `protobuf:"bytes,1,opt,name=storeID,proto3" json:"storeID,omitempty"` - ModelName string `protobuf:"bytes,2,opt,name=modelName,proto3" json:"modelName,omitempty"` - EntityID string `protobuf:"bytes,3,opt,name=entityID,proto3" json:"entityID,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + StoreID string `protobuf:"bytes,1,opt,name=storeID,proto3" json:"storeID,omitempty"` + Filters []*ListenRequest_Filter `protobuf:"bytes,2,rep,name=filters,proto3" json:"filters,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *ListenRequest) Reset() { *m = ListenRequest{} } @@ -1574,25 +1632,75 @@ func (m *ListenRequest) GetStoreID() string { return "" } -func (m *ListenRequest) GetModelName() string { +func (m *ListenRequest) GetFilters() []*ListenRequest_Filter { + if m != nil { + return m.Filters + } + return nil +} + +type ListenRequest_Filter struct { + ModelName string `protobuf:"bytes,1,opt,name=modelName,proto3" json:"modelName,omitempty"` + EntityID string `protobuf:"bytes,2,opt,name=entityID,proto3" json:"entityID,omitempty"` + Action ListenRequest_Filter_Action `protobuf:"varint,3,opt,name=action,proto3,enum=api.pb.ListenRequest_Filter_Action" json:"action,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListenRequest_Filter) Reset() { *m = ListenRequest_Filter{} } +func (m *ListenRequest_Filter) String() string { return proto.CompactTextString(m) } +func (*ListenRequest_Filter) ProtoMessage() {} +func (*ListenRequest_Filter) Descriptor() ([]byte, []int) { + return fileDescriptor_00212fb1f9d3bf1c, []int{27, 0} +} + +func (m *ListenRequest_Filter) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ListenRequest_Filter.Unmarshal(m, b) +} +func (m *ListenRequest_Filter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ListenRequest_Filter.Marshal(b, m, deterministic) +} +func (m *ListenRequest_Filter) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListenRequest_Filter.Merge(m, src) +} +func (m *ListenRequest_Filter) XXX_Size() int { + return xxx_messageInfo_ListenRequest_Filter.Size(m) +} +func (m *ListenRequest_Filter) XXX_DiscardUnknown() { + xxx_messageInfo_ListenRequest_Filter.DiscardUnknown(m) +} + +var xxx_messageInfo_ListenRequest_Filter proto.InternalMessageInfo + +func (m *ListenRequest_Filter) GetModelName() string { if m != nil { return m.ModelName } return "" } -func (m *ListenRequest) GetEntityID() string { +func (m *ListenRequest_Filter) GetEntityID() string { if m != nil { return m.EntityID } return "" } +func (m *ListenRequest_Filter) GetAction() ListenRequest_Filter_Action { + if m != nil { + return m.Action + } + return ListenRequest_Filter_ALL +} + type ListenReply struct { - Entity string `protobuf:"bytes,1,opt,name=entity,proto3" json:"entity,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + ModelName string `protobuf:"bytes,1,opt,name=modelName,proto3" json:"modelName,omitempty"` + EntityID string `protobuf:"bytes,2,opt,name=entityID,proto3" json:"entityID,omitempty"` + Action ListenReply_Action `protobuf:"varint,3,opt,name=action,proto3,enum=api.pb.ListenReply_Action" json:"action,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *ListenReply) Reset() { *m = ListenReply{} } @@ -1620,14 +1728,30 @@ func (m *ListenReply) XXX_DiscardUnknown() { var xxx_messageInfo_ListenReply proto.InternalMessageInfo -func (m *ListenReply) GetEntity() string { +func (m *ListenReply) GetModelName() string { if m != nil { - return m.Entity + return m.ModelName + } + return "" +} + +func (m *ListenReply) GetEntityID() string { + if m != nil { + return m.EntityID } return "" } +func (m *ListenReply) GetAction() ListenReply_Action { + if m != nil { + return m.Action + } + return ListenReply_CREATE +} + func init() { + proto.RegisterEnum("api.pb.ListenRequest_Filter_Action", ListenRequest_Filter_Action_name, ListenRequest_Filter_Action_value) + proto.RegisterEnum("api.pb.ListenReply_Action", ListenReply_Action_name, ListenReply_Action_value) proto.RegisterType((*NewStoreRequest)(nil), "api.pb.NewStoreRequest") proto.RegisterType((*NewStoreReply)(nil), "api.pb.NewStoreReply") proto.RegisterType((*RegisterSchemaRequest)(nil), "api.pb.RegisterSchemaRequest") @@ -1656,81 +1780,90 @@ func init() { proto.RegisterType((*WriteTransactionRequest)(nil), "api.pb.WriteTransactionRequest") proto.RegisterType((*WriteTransactionReply)(nil), "api.pb.WriteTransactionReply") proto.RegisterType((*ListenRequest)(nil), "api.pb.ListenRequest") + proto.RegisterType((*ListenRequest_Filter)(nil), "api.pb.ListenRequest.Filter") proto.RegisterType((*ListenReply)(nil), "api.pb.ListenReply") } func init() { proto.RegisterFile("api.proto", fileDescriptor_00212fb1f9d3bf1c) } var fileDescriptor_00212fb1f9d3bf1c = []byte{ - // 1085 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xef, 0x6e, 0xdb, 0x36, - 0x10, 0x97, 0xed, 0xc4, 0x89, 0xcf, 0x89, 0xe3, 0x32, 0x71, 0xec, 0x69, 0xee, 0x52, 0x10, 0x18, - 0x96, 0x0f, 0x85, 0x57, 0xb8, 0x5f, 0x36, 0x60, 0xc3, 0xd6, 0xd4, 0xcd, 0xec, 0x35, 0xcb, 0x3a, - 0xd9, 0xc3, 0x06, 0x0c, 0x43, 0xa1, 0xc4, 0x5c, 0xa2, 0x4e, 0xb2, 0x5c, 0x49, 0x69, 0xeb, 0x07, - 0xd8, 0x8b, 0xec, 0x51, 0x06, 0xec, 0x3d, 0xf6, 0x04, 0xdb, 0x2b, 0x0c, 0xa4, 0x48, 0x4a, 0x94, - 0x28, 0xe7, 0x83, 0x9d, 0x7e, 0x33, 0x8f, 0xf7, 0xe7, 0x77, 0xc7, 0xfb, 0x1d, 0x45, 0x43, 0xcd, - 0x9e, 0x3b, 0xbd, 0x79, 0xe0, 0x47, 0x3e, 0xaa, 0xb2, 0x9f, 0x17, 0xf8, 0x1e, 0xec, 0x9d, 0x93, - 0xb7, 0xe3, 0xc8, 0x0f, 0x88, 0x45, 0x5e, 0xdf, 0x90, 0x30, 0xc2, 0x47, 0xb0, 0x9b, 0x88, 0xe6, - 0xee, 0x02, 0x35, 0xa0, 0x3c,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 0x13, 0x52, 0x34, 0x64, 0x42, 0xea, 0x45, 0x25, 0xda, - 0x2b, 0x75, 0x51, 0x68, 0xdb, 0x2b, 0xb5, 0x2f, 0xdb, 0x2b, 0x7d, 0xb9, 0x08, 0x54, 0xca, 0xe8, - 0xe7, 0xcd, 0xa5, 0xa2, 0x52, 0x34, 0x24, 0x2a, 0xf5, 0xca, 0xd0, 0x30, 0x67, 0x73, 0x2d, 0xcc, - 0xa9, 0xae, 0x91, 0x39, 0x5b, 0x6b, 0x61, 0xce, 0x5f, 0x15, 0x68, 0xe5, 0xfb, 0x88, 0x76, 0xae, - 0xc0, 0x9f, 0xba, 0xf3, 0x79, 0xfb, 0x74, 0xb4, 0xc7, 0x1c, 0x77, 0x6d, 0xce, 0x46, 0x72, 0x48, - 0xde, 0xd3, 0x5a, 0x0e, 0xc9, 0x5d, 0xc9, 0x21, 0x29, 0x91, 0x48, 0x52, 0x77, 0xad, 0xb6, 0x49, - 0x52, 0xfb, 0x12, 0x49, 0x4a, 0x96, 0x1f, 0x06, 0x1b, 0x2b, 0x0e, 0x83, 0xcd, 0xb5, 0x0c, 0x83, - 0xea, 0xca, 0xc3, 0xe0, 0x12, 0x76, 0xcf, 0xe8, 0xe7, 0xf8, 0xec, 0x2e, 0xef, 0xd1, 0x8f, 0xa1, - 0x2e, 0x82, 0x2c, 0xb9, 0x40, 0xfb, 0xff, 0x6e, 0x41, 0xe5, 0xc9, 0x8b, 0x11, 0xfa, 0x02, 0xb6, - 0xc5, 0x23, 0x05, 0x49, 0xda, 0x64, 0x5e, 0x32, 0x66, 0x2b, 0xbf, 0x41, 0x3f, 0xa4, 0x0c, 0x74, - 0x0e, 0x0d, 0xf5, 0x89, 0x81, 0xee, 0x0b, 0x55, 0xed, 0xcb, 0xc6, 0xfc, 0xb0, 0x68, 0x3b, 0xf6, - 0xf7, 0x18, 0x36, 0xd9, 0xac, 0x43, 0x07, 0xca, 0xe8, 0x13, 0xd6, 0x28, 0x23, 0x8d, 0x8d, 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 0x6b, 0xfa, 0x4c, 0x0d, 0x4f, 0x1a, 0x93, 0x58, 0x30, 0x89, - 0xd7, 0x2f, 0x4a, 0x7f, 0x96, 0x2b, 0x93, 0xc9, 0xb3, 0x8b, 0x2a, 0xfb, 0xab, 0xe3, 0xf1, 0xff, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x6e, 0x19, 0xee, 0x52, 0xf7, 0x10, 0x00, 0x00, + // 1209 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xdd, 0x6e, 0xe3, 0x44, + 0x14, 0xb6, 0x93, 0xd6, 0x6d, 0x4e, 0xda, 0x34, 0x3b, 0x6d, 0xda, 0x60, 0xb2, 0x74, 0x35, 0x5c, + 0x50, 0xa1, 0x55, 0x58, 0xa5, 0x12, 0x02, 0x01, 0x82, 0xb6, 0x49, 0x49, 0xd8, 0x50, 0x16, 0x27, + 0xfc, 0x48, 0x08, 0xad, 0xdc, 0x66, 0xb6, 0xf5, 0xe2, 0xfc, 0xac, 0xed, 0xee, 0x6e, 0x1e, 0x80, + 0x77, 0xe0, 0x9a, 0x1b, 0x5e, 0x80, 0x27, 0x40, 0xe2, 0x3d, 0x78, 0x02, 0x78, 0x05, 0x34, 0xe3, + 0xf1, 0xd8, 0x63, 0x8f, 0x53, 0x44, 0xb3, 0x7b, 0x97, 0x39, 0x73, 0x7e, 0xbe, 0x73, 0xe6, 0x9b, + 0x73, 0x3c, 0x81, 0x92, 0x3d, 0x73, 0x9a, 0x33, 0x6f, 0x1a, 0x4c, 0x91, 0xc1, 0x7e, 0x9e, 0xe3, + 0x3b, 0xb0, 0x75, 0x46, 0x5e, 0x0c, 0x82, 0xa9, 0x47, 0x2c, 0xf2, 0xec, 0x9a, 0xf8, 0x01, 0xde, + 0x87, 0xcd, 0x58, 0x34, 0x73, 0xe7, 0xa8, 0x02, 0x85, 0x5e, 0xbb, 0xae, 0xdf, 0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xd2, + 0x10, 0x09, 0xc9, 0x83, 0x2a, 0xa2, 0x57, 0x62, 0x50, 0x28, 0xe9, 0x95, 0xd8, 0x17, 0xf4, 0x4a, + 0x0e, 0x97, 0x08, 0x95, 0xd4, 0xfa, 0x39, 0xb9, 0x64, 0x54, 0x92, 0x86, 0x40, 0x25, 0x8f, 0x0c, + 0xc5, 0xcd, 0x59, 0x5d, 0xca, 0xcd, 0x31, 0x96, 0x78, 0x73, 0xd6, 0x96, 0x72, 0x73, 0xfe, 0x28, + 0x42, 0x2d, 0xcb, 0x23, 0xca, 0xdc, 0x08, 0x7f, 0x62, 0xe6, 0x73, 0xfa, 0xd4, 0x95, 0xc7, 0x1c, + 0xb2, 0x36, 0x63, 0x23, 0xee, 0x90, 0x98, 0xd3, 0xca, 0x3b, 0x24, 0x76, 0xc5, 0x1d, 0x12, 0x12, + 0x81, 0x24, 0x31, 0x6b, 0x95, 0x24, 0x49, 0xec, 0x0b, 0x24, 0x09, 0x59, 0xb6, 0x19, 0xac, 0xdc, + 0xb2, 0x19, 0xac, 0x2e, 0xa5, 0x19, 0x18, 0xb7, 0x6e, 0x06, 0xbf, 0x14, 0x60, 0xb3, 0x4f, 0xbf, + 0xc7, 0xff, 0xc3, 0xac, 0x7a, 0x1f, 0xd6, 0x9e, 0x38, 0x6e, 0x40, 0x3c, 0xfa, 0xdd, 0x5c, 0x4c, + 0x32, 0x48, 0xf2, 0xd0, 0x3c, 0x65, 0x4a, 0x56, 0xa4, 0x6c, 0xfe, 0xae, 0x83, 0x11, 0xca, 0xe4, + 0x71, 0xa7, 0x2f, 0x9a, 0xc5, 0x05, 0x79, 0x16, 0xa3, 0x8f, 0xc0, 0x08, 0x29, 0xc6, 0xce, 0xaf, + 0xd2, 0x7a, 0x7b, 0x51, 0xec, 0xe6, 0x51, 0xc8, 0x46, 0x6e, 0x82, 0x0f, 0xc1, 0x08, 0x25, 0x68, + 0x0d, 0x8a, 0x47, 0xfd, 0x7e, 0x55, 0x43, 0x00, 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ed, 0x74, 0x58, + 0xa3, 0x8c, 0x89, 0x5a, 0x17, 0xca, 0x9b, 0x50, 0xa6, 0xba, 0xcb, 0x25, 0xb2, 0xa0, 0xcd, 0x05, + 0xe5, 0x8e, 0x26, 0x33, 0xa7, 0xcb, 0x61, 0x0d, 0x3d, 0xe4, 0xaf, 0x91, 0xa8, 0x3b, 0xa1, 0x85, + 0x33, 0xc9, 0x5c, 0xd0, 0xe8, 0xb0, 0x86, 0xbe, 0x81, 0xad, 0xd4, 0x87, 0x1c, 0x7a, 0x2b, 0x66, + 0xa8, 0xea, 0x23, 0xda, 0x6c, 0xe4, 0xee, 0x33, 0x97, 0x07, 0xfa, 0x03, 0x1d, 0x7d, 0x0f, 0xd5, + 0xf4, 0x94, 0x8b, 0x19, 0x99, 0xf3, 0x1d, 0x15, 0x33, 0x52, 0x39, 0x20, 0xb9, 0xe7, 0x0f, 0xc0, + 0x08, 0x1b, 0x00, 0xaa, 0x29, 0x9b, 0x99, 0xb9, 0xad, 0xe8, 0x13, 0x58, 0x7b, 0xa0, 0x1f, 0x7f, + 0x08, 0xfb, 0xce, 0xb4, 0x19, 0x90, 0x97, 0x81, 0xe3, 0x92, 0xe6, 0xa5, 0x37, 0xbb, 0x78, 0xcc, + 0x17, 0x8f, 0x83, 0x2b, 0xfa, 0xbe, 0xf7, 0x8f, 0x2b, 0xc3, 0x50, 0x30, 0x0c, 0xd7, 0x8f, 0xf4, + 0x5f, 0x0b, 0xc5, 0xe1, 0xb0, 0x73, 0x6e, 0xb0, 0xff, 0x88, 0x0e, 0xff, 0x0d, 0x00, 0x00, 0xff, + 0xff, 0x73, 0xa4, 0x01, 0x2b, 0x30, 0x12, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/api/pb/api.proto b/api/pb/api.proto index 3d82c3ef..1f5a365e 100644 --- a/api/pb/api.proto +++ b/api/pb/api.proto @@ -164,13 +164,13 @@ message ListenRequest { message ListenReply { string modelName = 1; + string entityID = 2; enum Action { CREATE = 0; SAVE = 1; DELETE = 2; } - Action action = 2; - string entity = 3; + Action action = 3; } service API { diff --git a/api/service.go b/api/service.go index 30c29a7d..5664059a 100644 --- a/api/service.go +++ b/api/service.go @@ -329,19 +329,32 @@ func (s *service) WriteTransaction(stream pb.API_WriteTransactionServer) error { // Listen returns a stream of entities, trigged by a local or remote state change. func (s *service) Listen(req *pb.ListenRequest, server pb.API_ListenServer) error { - log.Debugf("received listen request for entity %s", req.EntityID) - store, err := s.getStore(req.StoreID) if err != nil { return err } - model := store.GetModel(req.ModelName) - if model == nil { - return status.Error(codes.NotFound, "model not found") + options := make([]es.ListenOption, len(req.GetFilters())) + for i, filter := range req.GetFilters() { + var listenActionType es.ListenActionType + switch filter.GetAction() { + case pb.ListenRequest_Filter_ALL: + listenActionType = es.ListenAll + case pb.ListenRequest_Filter_CREATE: + listenActionType = es.ListenCreate + case pb.ListenRequest_Filter_DELETE: + listenActionType = es.ListenDelete + case pb.ListenRequest_Filter_SAVE: + listenActionType = es.ListenSave + } + options[i] = es.ListenOption{ + Type: listenActionType, + Model: filter.GetModelName(), + ID: core.EntityID(filter.EntityID), + } } - l, err := store.Listen(es.ListenOption{Model: req.ModelName, ID: core.EntityID(req.EntityID)}) + l, err := store.Listen(options...) if err != nil { return err } @@ -351,19 +364,26 @@ func (s *service) Listen(req *pb.ListenRequest, server pb.API_ListenServer) erro select { case <-server.Context().Done(): return nil - case _, ok := <-l.Channel(): + case action, ok := <-l.Channel(): if !ok { return nil } - err := model.ReadTxn(func(txn *es.Txn) error { - var res string - if err := txn.FindByID(core.EntityID(req.EntityID), &res); err != nil { - return err - } - return server.Send(&pb.ListenReply{ - Entity: res, - }) - }) + var replyAction pb.ListenReply_Action + switch action.Type { + case es.ActionCreate: + replyAction = pb.ListenReply_CREATE + case es.ActionDelete: + replyAction = pb.ListenReply_DELETE + case es.ActionSave: + replyAction = pb.ListenReply_SAVE + } + // TODO: do we want to send the entity data in case of create and save? + reply := &pb.ListenReply{ + ModelName: action.Model, + EntityID: action.ID.String(), + Action: replyAction, + } + err := server.Send(reply) if err != nil { return err }