From 1169391de4ff03aaf9a7888667275659f7d5d385 Mon Sep 17 00:00:00 2001 From: Marcel Lanz Date: Wed, 13 Jan 2021 16:47:12 +0100 Subject: [PATCH] feature/issue 59 (#69) * [issue59] Added Passivation Strategy options and adapted to new TCK tests. Passes with 186/186. * [issue59] added optional comma in aggregated prototext value; to be inline with the main repository. * [issue59] aligned with minor differences in *.proto files regarding formatting and small differences like options. --- cloudstate/cloudstate.go | 9 +- cloudstate/crdt/entity.go | 26 +- cloudstate/discovery/server.go | 32 ++- cloudstate/eventsourced/entity.go | 25 ++ cloudstate/protocol/entity.pb.go | 271 +++++++++++++++--- cloudstate/value/context.go | 15 + cloudstate/value/entity.go | 40 +++ cloudstate/value/server.go | 15 + example/valueentity/entity.go | 1 - protobuf/protocol/cloudstate/action.proto | 2 +- protobuf/protocol/cloudstate/crdt.proto | 2 +- protobuf/protocol/cloudstate/entity.proto | 23 ++ .../protocol/cloudstate/event_sourced.proto | 3 +- .../tck/model/eventlogeventing.proto | 21 +- .../cloudstate/tck/model/eventsourced.proto | 6 +- .../tck/model/tck_valueentity.proto | 6 +- protobuf/tck/tck_crdt2.proto | 6 +- tck/cmd/tck_eventsourced/tck_eventsourced.go | 45 ++- tck/crdt2/model.go | 19 ++ tck/crdt2/tck_crdt2.pb.go | 32 ++- tck/crdt2/tck_crdt2_grpc.pb.go | 83 ++++++ tck/eventlogeventing/eventlogeventing.pb.go | 1 - tck/eventsourced/eventsourced.pb.go | 34 ++- tck/eventsourced/eventsourced_grpc.pb.go | 84 ++++++ tck/eventsourced/model.go | 15 + tck/value/model.go | 15 + tck/value/tck_valueentity.pb.go | 35 ++- tck/value/tck_valueentity_grpc.pb.go | 83 ++++++ 28 files changed, 815 insertions(+), 134 deletions(-) diff --git a/cloudstate/cloudstate.go b/cloudstate/cloudstate.go index 9f627f5..168caab 100644 --- a/cloudstate/cloudstate.go +++ b/cloudstate/cloudstate.go @@ -61,7 +61,8 @@ func New(c protocol.Config) (*CloudState, error) { } // RegisterEventSourced registers an event sourced entity. -func (cs *CloudState) RegisterEventSourced(entity *eventsourced.Entity, config protocol.DescriptorConfig) error { +func (cs *CloudState) RegisterEventSourced(entity *eventsourced.Entity, config protocol.DescriptorConfig, options ...eventsourced.Option) error { + entity.Options(options...) if err := cs.eventSourcedServer.Register(entity); err != nil { return err } @@ -72,7 +73,8 @@ func (cs *CloudState) RegisterEventSourced(entity *eventsourced.Entity, config p } // RegisterCRDT registers a CRDT entity. -func (cs *CloudState) RegisterCRDT(entity *crdt.Entity, config protocol.DescriptorConfig) error { +func (cs *CloudState) RegisterCRDT(entity *crdt.Entity, config protocol.DescriptorConfig, options ...crdt.Option) error { + entity.Options(options...) if err := cs.crdtServer.Register(entity); err != nil { return err } @@ -94,7 +96,8 @@ func (cs *CloudState) RegisterAction(entity *action.Entity, config protocol.Desc } // RegisterValueEntity registers a Value entity. -func (cs *CloudState) RegisterValueEntity(entity *value.Entity, config protocol.DescriptorConfig) error { +func (cs *CloudState) RegisterValueEntity(entity *value.Entity, config protocol.DescriptorConfig, options ...value.Option) error { + entity.Options(options...) if err := cs.valueServer.Register(entity); err != nil { return err } diff --git a/cloudstate/crdt/entity.go b/cloudstate/crdt/entity.go index 5c862c7..e0346fa 100644 --- a/cloudstate/crdt/entity.go +++ b/cloudstate/crdt/entity.go @@ -16,6 +16,9 @@ package crdt import ( + "time" + + "github.com/cloudstateio/go-support/cloudstate/protocol" "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes/any" ) @@ -27,7 +30,28 @@ type Entity struct { // this entities interface. Setting it is mandatory. ServiceName ServiceName // EntityFunc creates a new entity. - EntityFunc func(id EntityID) EntityHandler + EntityFunc func(id EntityID) EntityHandler + PassivationStrategy protocol.EntityPassivationStrategy +} + +type Option func(s *Entity) + +func (e *Entity) Options(options ...Option) { + for _, opt := range options { + opt(e) + } +} + +func WithPassivationStrategyTimeout(duration time.Duration) Option { + return func(e *Entity) { + e.PassivationStrategy = protocol.EntityPassivationStrategy{ + Strategy: &protocol.EntityPassivationStrategy_Timeout{ + Timeout: &protocol.TimeoutPassivationStrategy{ + Timeout: duration.Milliseconds(), + }, + }, + } + } } // EntityHandler has to be implemented by any type that wants to get diff --git a/cloudstate/discovery/server.go b/cloudstate/discovery/server.go index e635785..2ff6fd4 100644 --- a/cloudstate/discovery/server.go +++ b/cloudstate/discovery/server.go @@ -127,11 +127,15 @@ func (s *EntityDiscoveryServer) RegisterEventSourcedEntity(entity *eventsourced. if err := s.resolveFileDescriptors(config); err != nil { return fmt.Errorf("failed to resolve FileDescriptor for DescriptorConfig: %+v: %w", config, err) } - s.entitySpec.Entities = append(s.entitySpec.Entities, &protocol.Entity{ + e := &protocol.Entity{ EntityType: protocol.EventSourced, ServiceName: entity.ServiceName.String(), PersistenceId: entity.PersistenceID, - }) + } + if entity.PassivationStrategy.Strategy != nil { + e.PassivationStrategy = &entity.PassivationStrategy + } + s.entitySpec.Entities = append(s.entitySpec.Entities, e) return s.updateSpec() } @@ -141,12 +145,16 @@ func (s *EntityDiscoveryServer) RegisterCRDTEntity(entity *crdt.Entity, config p if err := s.resolveFileDescriptors(config); err != nil { return fmt.Errorf("failed to resolveFileDescriptor for DescriptorConfig: %+v: %w", config, err) } - s.entitySpec.Entities = append(s.entitySpec.Entities, &protocol.Entity{ - EntityType: protocol.CRDT, - ServiceName: entity.ServiceName.String(), - PersistenceId: entity.ServiceName.String(), // make sure CRDT entities have unique keys per service - - }) + e := &protocol.Entity{ + EntityType: protocol.CRDT, + ServiceName: entity.ServiceName.String(), + // TODO: as per https://github.com/cloudstateio/go-support/pull/67#issuecomment-749838999 this is temporary. + PersistenceId: entity.ServiceName.String(), // make sure CRDT entities have unique keys per service. + } + if entity.PassivationStrategy.GetStrategy() != nil { + e.PassivationStrategy = &entity.PassivationStrategy + } + s.entitySpec.Entities = append(s.entitySpec.Entities, e) return s.updateSpec() } @@ -169,11 +177,15 @@ func (s *EntityDiscoveryServer) RegisterValueEntity(entity *value.Entity, config if err := s.resolveFileDescriptors(config); err != nil { return fmt.Errorf("failed to resolveFileDescriptor for DescriptorConfig: %+v: %w", config, err) } - s.entitySpec.Entities = append(s.entitySpec.Entities, &protocol.Entity{ + e := &protocol.Entity{ EntityType: protocol.Value, ServiceName: entity.ServiceName.String(), PersistenceId: entity.PersistenceID, - }) + } + if entity.PassivationStrategy.GetStrategy() != nil { + e.PassivationStrategy = &entity.PassivationStrategy + } + s.entitySpec.Entities = append(s.entitySpec.Entities, e) return s.updateSpec() } diff --git a/cloudstate/eventsourced/entity.go b/cloudstate/eventsourced/entity.go index 831dd6c..1607b5b 100644 --- a/cloudstate/eventsourced/entity.go +++ b/cloudstate/eventsourced/entity.go @@ -16,6 +16,9 @@ package eventsourced import ( + "time" + + "github.com/cloudstateio/go-support/cloudstate/protocol" "github.com/golang/protobuf/proto" ) @@ -40,6 +43,28 @@ type Entity struct { SnapshotEvery int64 // EntityFunc is a factory method which generates a new Entity. EntityFunc func(id EntityID) EntityHandler + + PassivationStrategy protocol.EntityPassivationStrategy +} + +type Option func(s *Entity) + +func (e *Entity) Options(options ...Option) { + for _, opt := range options { + opt(e) + } +} + +func WithPassivationStrategyTimeout(duration time.Duration) Option { + return func(e *Entity) { + e.PassivationStrategy = protocol.EntityPassivationStrategy{ + Strategy: &protocol.EntityPassivationStrategy_Timeout{ + Timeout: &protocol.TimeoutPassivationStrategy{ + Timeout: duration.Milliseconds(), + }, + }, + } + } } type ( diff --git a/cloudstate/protocol/entity.pb.go b/cloudstate/protocol/entity.pb.go index e963c0a..36ff075 100644 --- a/cloudstate/protocol/entity.pb.go +++ b/cloudstate/protocol/entity.pb.go @@ -969,6 +969,8 @@ type Entity struct { // The ID to namespace state by. How this is used depends on the type of entity, for example, // event sourced entities will prefix this to the persistence id. PersistenceId string `protobuf:"bytes,3,opt,name=persistence_id,json=persistenceId,proto3" json:"persistence_id,omitempty"` + // The passivation strategy for the entity. + PassivationStrategy *EntityPassivationStrategy `protobuf:"bytes,4,opt,name=passivation_strategy,json=passivationStrategy,proto3" json:"passivation_strategy,omitempty"` } func (x *Entity) Reset() { @@ -1024,6 +1026,136 @@ func (x *Entity) GetPersistenceId() string { return "" } +func (x *Entity) GetPassivationStrategy() *EntityPassivationStrategy { + if x != nil { + return x.PassivationStrategy + } + return nil +} + +// +// The semantics is to provide a flexible way for entity user functions to configure the passivation strategy. +// This strategy is sent to the proxy at discovery time allowing the proxy to configure the corresponding entities. +// The only passivation strategy supported is the timeout strategy and configuring this is optional for the entity. +// If an entity user function does not configure the passivation strategy the proxy uses its fallback default value. +// +// The passivation strategy for the entity user function. +type EntityPassivationStrategy struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Strategy: + // *EntityPassivationStrategy_Timeout + Strategy isEntityPassivationStrategy_Strategy `protobuf_oneof:"strategy"` +} + +func (x *EntityPassivationStrategy) Reset() { + *x = EntityPassivationStrategy{} + if protoimpl.UnsafeEnabled { + mi := &file_entity_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EntityPassivationStrategy) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EntityPassivationStrategy) ProtoMessage() {} + +func (x *EntityPassivationStrategy) ProtoReflect() protoreflect.Message { + mi := &file_entity_proto_msgTypes[12] + 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 EntityPassivationStrategy.ProtoReflect.Descriptor instead. +func (*EntityPassivationStrategy) Descriptor() ([]byte, []int) { + return file_entity_proto_rawDescGZIP(), []int{12} +} + +func (m *EntityPassivationStrategy) GetStrategy() isEntityPassivationStrategy_Strategy { + if m != nil { + return m.Strategy + } + return nil +} + +func (x *EntityPassivationStrategy) GetTimeout() *TimeoutPassivationStrategy { + if x, ok := x.GetStrategy().(*EntityPassivationStrategy_Timeout); ok { + return x.Timeout + } + return nil +} + +type isEntityPassivationStrategy_Strategy interface { + isEntityPassivationStrategy_Strategy() +} + +type EntityPassivationStrategy_Timeout struct { + // the timeout passivation strategy. + Timeout *TimeoutPassivationStrategy `protobuf:"bytes,1,opt,name=timeout,proto3,oneof"` +} + +func (*EntityPassivationStrategy_Timeout) isEntityPassivationStrategy_Strategy() {} + +// A passivation strategy based on a timeout. The idle timeout after which a user function's entity is passivated. +type TimeoutPassivationStrategy struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The timeout in millis + Timeout int64 `protobuf:"varint,1,opt,name=timeout,proto3" json:"timeout,omitempty"` +} + +func (x *TimeoutPassivationStrategy) Reset() { + *x = TimeoutPassivationStrategy{} + if protoimpl.UnsafeEnabled { + mi := &file_entity_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TimeoutPassivationStrategy) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TimeoutPassivationStrategy) ProtoMessage() {} + +func (x *TimeoutPassivationStrategy) ProtoReflect() protoreflect.Message { + mi := &file_entity_proto_msgTypes[13] + 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 TimeoutPassivationStrategy.ProtoReflect.Descriptor instead. +func (*TimeoutPassivationStrategy) Descriptor() ([]byte, []int) { + return file_entity_proto_rawDescGZIP(), []int{13} +} + +func (x *TimeoutPassivationStrategy) GetTimeout() int64 { + if x != nil { + return x.Timeout + } + return 0 +} + type UserFunctionError struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1035,7 +1167,7 @@ type UserFunctionError struct { func (x *UserFunctionError) Reset() { *x = UserFunctionError{} if protoimpl.UnsafeEnabled { - mi := &file_entity_proto_msgTypes[12] + mi := &file_entity_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1048,7 +1180,7 @@ func (x *UserFunctionError) String() string { func (*UserFunctionError) ProtoMessage() {} func (x *UserFunctionError) ProtoReflect() protoreflect.Message { - mi := &file_entity_proto_msgTypes[12] + mi := &file_entity_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1061,7 +1193,7 @@ func (x *UserFunctionError) ProtoReflect() protoreflect.Message { // Deprecated: Use UserFunctionError.ProtoReflect.Descriptor instead. func (*UserFunctionError) Descriptor() ([]byte, []int) { - return file_entity_proto_rawDescGZIP(), []int{12} + return file_entity_proto_rawDescGZIP(), []int{14} } func (x *UserFunctionError) GetMessage() string { @@ -1086,7 +1218,7 @@ type ProxyInfo struct { func (x *ProxyInfo) Reset() { *x = ProxyInfo{} if protoimpl.UnsafeEnabled { - mi := &file_entity_proto_msgTypes[13] + mi := &file_entity_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1099,7 +1231,7 @@ func (x *ProxyInfo) String() string { func (*ProxyInfo) ProtoMessage() {} func (x *ProxyInfo) ProtoReflect() protoreflect.Message { - mi := &file_entity_proto_msgTypes[13] + mi := &file_entity_proto_msgTypes[15] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1112,7 +1244,7 @@ func (x *ProxyInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use ProxyInfo.ProtoReflect.Descriptor instead. func (*ProxyInfo) Descriptor() ([]byte, []int) { - return file_entity_proto_rawDescGZIP(), []int{13} + return file_entity_proto_rawDescGZIP(), []int{15} } func (x *ProxyInfo) GetProtocolMajorVersion() int32 { @@ -1267,14 +1399,30 @@ var file_entity_proto_rawDesc = []byte{ 0x12, 0x34, 0x0a, 0x16, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x14, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x4d, 0x69, 0x6e, 0x6f, 0x72, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x73, 0x0a, 0x06, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, - 0x12, 0x1f, 0x0a, 0x0b, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, - 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x65, - 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x22, 0x2d, 0x0a, 0x11, 0x55, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xcd, 0x01, 0x0a, 0x06, 0x45, 0x6e, 0x74, 0x69, 0x74, + 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, + 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, + 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x12, 0x58, 0x0a, 0x14, + 0x70, 0x61, 0x73, 0x73, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, + 0x74, 0x65, 0x67, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x63, 0x6c, 0x6f, + 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x50, 0x61, + 0x73, 0x73, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, + 0x79, 0x52, 0x13, 0x70, 0x61, 0x73, 0x73, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, + 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x22, 0x6b, 0x0a, 0x19, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, + 0x50, 0x61, 0x73, 0x73, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, + 0x65, 0x67, 0x79, 0x12, 0x42, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x50, 0x61, 0x73, 0x73, 0x69, 0x76, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x48, 0x00, 0x52, 0x07, + 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x42, 0x0a, 0x0a, 0x08, 0x73, 0x74, 0x72, 0x61, 0x74, + 0x65, 0x67, 0x79, 0x22, 0x36, 0x0a, 0x1a, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x50, 0x61, + 0x73, 0x73, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, + 0x79, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x22, 0x2d, 0x0a, 0x11, 0x55, 0x73, 0x65, 0x72, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xf1, 0x01, 0x0a, 0x09, 0x50, @@ -1323,49 +1471,53 @@ func file_entity_proto_rawDescGZIP() []byte { return file_entity_proto_rawDescData } -var file_entity_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_entity_proto_msgTypes = make([]protoimpl.MessageInfo, 16) var file_entity_proto_goTypes = []interface{}{ - (*Metadata)(nil), // 0: cloudstate.Metadata - (*MetadataEntry)(nil), // 1: cloudstate.MetadataEntry - (*Reply)(nil), // 2: cloudstate.Reply - (*Forward)(nil), // 3: cloudstate.Forward - (*ClientAction)(nil), // 4: cloudstate.ClientAction - (*SideEffect)(nil), // 5: cloudstate.SideEffect - (*Command)(nil), // 6: cloudstate.Command - (*StreamCancelled)(nil), // 7: cloudstate.StreamCancelled - (*Failure)(nil), // 8: cloudstate.Failure - (*EntitySpec)(nil), // 9: cloudstate.EntitySpec - (*ServiceInfo)(nil), // 10: cloudstate.ServiceInfo - (*Entity)(nil), // 11: cloudstate.Entity - (*UserFunctionError)(nil), // 12: cloudstate.UserFunctionError - (*ProxyInfo)(nil), // 13: cloudstate.ProxyInfo - (*any.Any)(nil), // 14: google.protobuf.Any - (*empty.Empty)(nil), // 15: google.protobuf.Empty + (*Metadata)(nil), // 0: cloudstate.Metadata + (*MetadataEntry)(nil), // 1: cloudstate.MetadataEntry + (*Reply)(nil), // 2: cloudstate.Reply + (*Forward)(nil), // 3: cloudstate.Forward + (*ClientAction)(nil), // 4: cloudstate.ClientAction + (*SideEffect)(nil), // 5: cloudstate.SideEffect + (*Command)(nil), // 6: cloudstate.Command + (*StreamCancelled)(nil), // 7: cloudstate.StreamCancelled + (*Failure)(nil), // 8: cloudstate.Failure + (*EntitySpec)(nil), // 9: cloudstate.EntitySpec + (*ServiceInfo)(nil), // 10: cloudstate.ServiceInfo + (*Entity)(nil), // 11: cloudstate.Entity + (*EntityPassivationStrategy)(nil), // 12: cloudstate.EntityPassivationStrategy + (*TimeoutPassivationStrategy)(nil), // 13: cloudstate.TimeoutPassivationStrategy + (*UserFunctionError)(nil), // 14: cloudstate.UserFunctionError + (*ProxyInfo)(nil), // 15: cloudstate.ProxyInfo + (*any.Any)(nil), // 16: google.protobuf.Any + (*empty.Empty)(nil), // 17: google.protobuf.Empty } var file_entity_proto_depIdxs = []int32{ 1, // 0: cloudstate.Metadata.entries:type_name -> cloudstate.MetadataEntry - 14, // 1: cloudstate.Reply.payload:type_name -> google.protobuf.Any + 16, // 1: cloudstate.Reply.payload:type_name -> google.protobuf.Any 0, // 2: cloudstate.Reply.metadata:type_name -> cloudstate.Metadata - 14, // 3: cloudstate.Forward.payload:type_name -> google.protobuf.Any + 16, // 3: cloudstate.Forward.payload:type_name -> google.protobuf.Any 0, // 4: cloudstate.Forward.metadata:type_name -> cloudstate.Metadata 2, // 5: cloudstate.ClientAction.reply:type_name -> cloudstate.Reply 3, // 6: cloudstate.ClientAction.forward:type_name -> cloudstate.Forward 8, // 7: cloudstate.ClientAction.failure:type_name -> cloudstate.Failure - 14, // 8: cloudstate.SideEffect.payload:type_name -> google.protobuf.Any + 16, // 8: cloudstate.SideEffect.payload:type_name -> google.protobuf.Any 0, // 9: cloudstate.SideEffect.metadata:type_name -> cloudstate.Metadata - 14, // 10: cloudstate.Command.payload:type_name -> google.protobuf.Any + 16, // 10: cloudstate.Command.payload:type_name -> google.protobuf.Any 0, // 11: cloudstate.Command.metadata:type_name -> cloudstate.Metadata 11, // 12: cloudstate.EntitySpec.entities:type_name -> cloudstate.Entity 10, // 13: cloudstate.EntitySpec.service_info:type_name -> cloudstate.ServiceInfo - 13, // 14: cloudstate.EntityDiscovery.discover:input_type -> cloudstate.ProxyInfo - 12, // 15: cloudstate.EntityDiscovery.reportError:input_type -> cloudstate.UserFunctionError - 9, // 16: cloudstate.EntityDiscovery.discover:output_type -> cloudstate.EntitySpec - 15, // 17: cloudstate.EntityDiscovery.reportError:output_type -> google.protobuf.Empty - 16, // [16:18] is the sub-list for method output_type - 14, // [14:16] is the sub-list for method input_type - 14, // [14:14] is the sub-list for extension type_name - 14, // [14:14] is the sub-list for extension extendee - 0, // [0:14] is the sub-list for field type_name + 12, // 14: cloudstate.Entity.passivation_strategy:type_name -> cloudstate.EntityPassivationStrategy + 13, // 15: cloudstate.EntityPassivationStrategy.timeout:type_name -> cloudstate.TimeoutPassivationStrategy + 15, // 16: cloudstate.EntityDiscovery.discover:input_type -> cloudstate.ProxyInfo + 14, // 17: cloudstate.EntityDiscovery.reportError:input_type -> cloudstate.UserFunctionError + 9, // 18: cloudstate.EntityDiscovery.discover:output_type -> cloudstate.EntitySpec + 17, // 19: cloudstate.EntityDiscovery.reportError:output_type -> google.protobuf.Empty + 18, // [18:20] is the sub-list for method output_type + 16, // [16:18] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name } func init() { file_entity_proto_init() } @@ -1519,7 +1671,7 @@ func file_entity_proto_init() { } } file_entity_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UserFunctionError); i { + switch v := v.(*EntityPassivationStrategy); i { case 0: return &v.state case 1: @@ -1531,6 +1683,30 @@ func file_entity_proto_init() { } } file_entity_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TimeoutPassivationStrategy); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entity_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserFunctionError); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entity_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ProxyInfo); i { case 0: return &v.state @@ -1552,13 +1728,16 @@ func file_entity_proto_init() { (*ClientAction_Forward)(nil), (*ClientAction_Failure)(nil), } + file_entity_proto_msgTypes[12].OneofWrappers = []interface{}{ + (*EntityPassivationStrategy_Timeout)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_entity_proto_rawDesc, NumEnums: 0, - NumMessages: 14, + NumMessages: 16, NumExtensions: 0, NumServices: 1, }, diff --git a/cloudstate/value/context.go b/cloudstate/value/context.go index 3cc67ca..dee0105 100644 --- a/cloudstate/value/context.go +++ b/cloudstate/value/context.go @@ -1,3 +1,18 @@ +// +// Copyright 2019 Lightbend Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package value import ( diff --git a/cloudstate/value/entity.go b/cloudstate/value/entity.go index 645648d..6fb7810 100644 --- a/cloudstate/value/entity.go +++ b/cloudstate/value/entity.go @@ -1,6 +1,24 @@ +// +// Copyright 2019 Lightbend Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package value import ( + "time" + + "github.com/cloudstateio/go-support/cloudstate/protocol" "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes/any" ) @@ -12,6 +30,28 @@ type Entity struct { // EntityFunc creates a new entity. EntityFunc func(EntityID) EntityHandler PersistenceID string + + PassivationStrategy protocol.EntityPassivationStrategy +} + +type Option func(s *Entity) + +func (e *Entity) Options(options ...Option) { + for _, opt := range options { + opt(e) + } +} + +func WithPassivationStrategyTimeout(duration time.Duration) Option { + return func(e *Entity) { + e.PassivationStrategy = protocol.EntityPassivationStrategy{ + Strategy: &protocol.EntityPassivationStrategy_Timeout{ + Timeout: &protocol.TimeoutPassivationStrategy{ + Timeout: duration.Milliseconds(), + }, + }, + } + } } type EntityHandler interface { diff --git a/cloudstate/value/server.go b/cloudstate/value/server.go index 524ab35..37ff568 100644 --- a/cloudstate/value/server.go +++ b/cloudstate/value/server.go @@ -1,3 +1,18 @@ +// +// Copyright 2019 Lightbend Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package value import ( diff --git a/example/valueentity/entity.go b/example/valueentity/entity.go index 0ba79d1..4a79618 100644 --- a/example/valueentity/entity.go +++ b/example/valueentity/entity.go @@ -109,7 +109,6 @@ func (sc *ShoppingCart) HandleCommand(ctx *value.Context, name string, cmd proto } func (sc *ShoppingCart) HandleState(ctx *value.Context, state *any.Any) error { - return nil } diff --git a/protobuf/protocol/cloudstate/action.proto b/protobuf/protocol/cloudstate/action.proto index 3e0e173..a387ac7 100644 --- a/protobuf/protocol/cloudstate/action.proto +++ b/protobuf/protocol/cloudstate/action.proto @@ -129,4 +129,4 @@ service ActionProtocol { // through an HTTP2 stream RST message. rpc handleStreamed(stream ActionCommand) returns (stream ActionResponse) {} -} \ No newline at end of file +} diff --git a/protobuf/protocol/cloudstate/crdt.proto b/protobuf/protocol/cloudstate/crdt.proto index 8ec8966..b236e5d 100644 --- a/protobuf/protocol/cloudstate/crdt.proto +++ b/protobuf/protocol/cloudstate/crdt.proto @@ -244,4 +244,4 @@ enum CrdtClock { // Use a custom clock value, but automatically increment it by one if the clock // value from the current value is equal to the custom_clock_value. CUSTOM_AUTO_INCREMENT = 3; -} \ No newline at end of file +} diff --git a/protobuf/protocol/cloudstate/entity.proto b/protobuf/protocol/cloudstate/entity.proto index e7bd6a1..65f38b2 100644 --- a/protobuf/protocol/cloudstate/entity.proto +++ b/protobuf/protocol/cloudstate/entity.proto @@ -267,6 +267,29 @@ message Entity { // The ID to namespace state by. How this is used depends on the type of entity, for example, // event sourced entities will prefix this to the persistence id. string persistence_id = 3; + + // The passivation strategy for the entity. + EntityPassivationStrategy passivation_strategy = 4; +} + +// +// The semantics is to provide a flexible way for entity user functions to configure the passivation strategy. +// This strategy is sent to the proxy at discovery time allowing the proxy to configure the corresponding entities. +// The only passivation strategy supported is the timeout strategy and configuring this is optional for the entity. +// If an entity user function does not configure the passivation strategy the proxy uses its fallback default value. +// +// The passivation strategy for the entity user function. +message EntityPassivationStrategy { + oneof strategy { + // the timeout passivation strategy. + TimeoutPassivationStrategy timeout = 1; + } +} + +// A passivation strategy based on a timeout. The idle timeout after which a user function's entity is passivated. +message TimeoutPassivationStrategy { + // The timeout in millis + int64 timeout = 1; } message UserFunctionError { diff --git a/protobuf/protocol/cloudstate/event_sourced.proto b/protobuf/protocol/cloudstate/event_sourced.proto index 218a208..5232205 100644 --- a/protobuf/protocol/cloudstate/event_sourced.proto +++ b/protobuf/protocol/cloudstate/event_sourced.proto @@ -111,6 +111,5 @@ service EventSourced { // message. The entity should reply in order, and any events that the entity requests to be // persisted the entity should handle itself, applying them to its own state, as if they had // arrived as events when the event stream was being replayed on load. - rpc handle (stream EventSourcedStreamIn) returns (stream EventSourcedStreamOut) { - } + rpc handle(stream EventSourcedStreamIn) returns (stream EventSourcedStreamOut) {} } diff --git a/protobuf/tck/cloudstate/tck/model/eventlogeventing.proto b/protobuf/tck/cloudstate/tck/model/eventlogeventing.proto index cec5f6b..0462f89 100644 --- a/protobuf/tck/cloudstate/tck/model/eventlogeventing.proto +++ b/protobuf/tck/cloudstate/tck/model/eventlogeventing.proto @@ -47,17 +47,17 @@ import "cloudstate/entity_key.proto"; service EventLogSubscriberModel { rpc ProcessEventOne(EventOne) returns (Response) { option (.cloudstate.eventing) = { - in: { - event_log: "eventlogeventing-one" - } + in: { + event_log: "eventlogeventing-one" + } }; }; rpc ProcessEventTwo(EventTwo) returns (stream Response) { option (.cloudstate.eventing) = { - in: { - event_log: "eventlogeventing-one" - } + in: { + event_log: "eventlogeventing-one" + } }; }; @@ -65,9 +65,9 @@ service EventLogSubscriberModel { rpc ProcessAnyEvent(google.protobuf.Any) returns (Response) { option (.cloudstate.eventing) = { - in: { - event_log: "eventlogeventing-two" - } + in: { + event_log: "eventlogeventing-two" + } }; }; } @@ -86,7 +86,7 @@ service EventSourcedEntityOne { // // The `EventSourcedEntityTwo` service is an event sourced entity that should be implemented in the following ways: // -// - The `EmitJsonMethod` method should emit an event serialised as JSON. This event should: +// - The `EmitJsonEvent` method should emit an event serialised as JSON. This event should: // - Contain a single `message` property with the value of the `message` field in `JsonEvent`. // - Be serialized according to the Cloudstate JSON serialization conventions - that is, with the JSON serialized to // bytes, then placed into a protobuf message with a single bytes field with field number 1. @@ -139,7 +139,6 @@ message JsonEvent { // // - Reply: reply with the given message in a `Response`. // - Forward: forward to another service, in place of replying with a `Response`. -// - SideEffect: add a side effect to the current reply, forward, or failure. // message ProcessStep { oneof step { diff --git a/protobuf/tck/cloudstate/tck/model/eventsourced.proto b/protobuf/tck/cloudstate/tck/model/eventsourced.proto index 0da3a02..c65a91e 100644 --- a/protobuf/tck/cloudstate/tck/model/eventsourced.proto +++ b/protobuf/tck/cloudstate/tck/model/eventsourced.proto @@ -64,9 +64,9 @@ service EventSourcedTwo { // - The passivation strategy must be set with a timeout of 100 millis. // - The `Call` method is not required to do anything, and must return an empty `Response` message. // -// service EventSourcedConfigured { -// rpc Call(Request) returns (Response); -// } +service EventSourcedConfigured { + rpc Call(Request) returns (Response); +} // // A `Request` message contains any actions that the entity should process. diff --git a/protobuf/tck/cloudstate/tck/model/tck_valueentity.proto b/protobuf/tck/cloudstate/tck/model/tck_valueentity.proto index 4f1e63f..f7771fd 100644 --- a/protobuf/tck/cloudstate/tck/model/tck_valueentity.proto +++ b/protobuf/tck/cloudstate/tck/model/tck_valueentity.proto @@ -64,9 +64,9 @@ service ValueEntityTwo { // - The passivation strategy must be set with a timeout of 100 millis. // - The `Call` method is not required to do anything, and must return an empty `Response` message. // -// service ValueEntityConfigured { -// rpc Call(Request) returns (Response); -// } +service ValueEntityConfigured { + rpc Call(Request) returns (Response); +} // // A `Request` message contains any actions that the entity should process. diff --git a/protobuf/tck/tck_crdt2.proto b/protobuf/tck/tck_crdt2.proto index f671736..6ecf6c7 100644 --- a/protobuf/tck/tck_crdt2.proto +++ b/protobuf/tck/tck_crdt2.proto @@ -67,9 +67,9 @@ service CrdtTwo { // - The passivation strategy must be set with a timeout of 100 millis. // - The `Call` method is not required to do anything, and must return an empty `Response` message. // -// service CrdtConfigured { -// rpc Call(Request) returns (Response); -// } +service CrdtConfigured { + rpc Call(Request) returns (Response); +} // // A `Request` message contains any actions that the entity should process. diff --git a/tck/cmd/tck_eventsourced/tck_eventsourced.go b/tck/cmd/tck_eventsourced/tck_eventsourced.go index 32a972b..6fec086 100644 --- a/tck/cmd/tck_eventsourced/tck_eventsourced.go +++ b/tck/cmd/tck_eventsourced/tck_eventsourced.go @@ -17,6 +17,7 @@ package main import ( "log" + "time" "github.com/cloudstateio/go-support/cloudstate" "github.com/cloudstateio/go-support/cloudstate/action" @@ -25,7 +26,6 @@ import ( "github.com/cloudstateio/go-support/cloudstate/protocol" "github.com/cloudstateio/go-support/cloudstate/value" "github.com/cloudstateio/go-support/example/shoppingcart" - tck_value "github.com/cloudstateio/go-support/example/valueentity" actionTCK "github.com/cloudstateio/go-support/tck/action" "github.com/cloudstateio/go-support/tck/crdt2" "github.com/cloudstateio/go-support/tck/eventlogeventing" @@ -68,6 +68,21 @@ func main() { if err != nil { log.Fatalf("Cloudstate failed to register entity: %s", err) } + err = server.RegisterEventSourced( + &eventsourced.Entity{ + ServiceName: "cloudstate.tck.model.EventSourcedConfigured", + PersistenceID: "event-sourced-configured", + SnapshotEvery: 5, + EntityFunc: tck.NewEventSourcedConfiguredEntity, + }, protocol.DescriptorConfig{ + Service: "eventsourced.proto", + }, + eventsourced.WithPassivationStrategyTimeout(100*time.Millisecond), + ) + if err != nil { + log.Fatalf("Cloudstate failed to register entity: %s", err) + } + // tag::event-sourced-entity-type[] // tag::register[] err = server.RegisterEventSourced(&eventsourced.Entity{ @@ -120,6 +135,16 @@ func main() { if err != nil { log.Fatalf("CloudState failed to register entity: %s", err) } + err = server.RegisterCRDT(&crdt.Entity{ + ServiceName: "cloudstate.tck.model.crdt.CrdtConfigured", + EntityFunc: crdt2.NewCrdtConfiguredEntity, + }, protocol.DescriptorConfig{ + Service: "tck_crdt2.proto", + }, crdt.WithPassivationStrategyTimeout(100*time.Millisecond)) + if err != nil { + log.Fatalf("CloudState failed to register entity: %s", err) + } + err = server.RegisterValueEntity(&value.Entity{ ServiceName: "cloudstate.tck.model.valueentity.ValueEntityTckModel", EntityFunc: valueentity.NewValueEntityTckModelEntity, @@ -140,15 +165,15 @@ func main() { if err != nil { log.Fatalf("CloudState failed to register entity: %s", err) } - - // value entity ShoppingCart - err = server.RegisterValueEntity(&value.Entity{ - ServiceName: "com.example.valueentity.shoppingcart.ShoppingCart", - EntityFunc: tck_value.NewShoppingCart, - PersistenceID: "shopping-cart", - }, protocol.DescriptorConfig{ - Service: "value_shoppingcart.proto", - }) + err = server.RegisterValueEntity( + &value.Entity{ + ServiceName: "cloudstate.tck.model.valueentity.ValueEntityConfigured", + EntityFunc: valueentity.NewValueEntityConfiguredEntity, + PersistenceID: "value-entity-configured", + }, protocol.DescriptorConfig{ + Service: "tck_valueentity.proto", + }, value.WithPassivationStrategyTimeout(100*time.Millisecond), + ) if err != nil { log.Fatalf("CloudState failed to register entity: %s", err) } diff --git a/tck/crdt2/model.go b/tck/crdt2/model.go index e817783..5c5d64e 100644 --- a/tck/crdt2/model.go +++ b/tck/crdt2/model.go @@ -415,3 +415,22 @@ func (CrdtTwoEntity) Default(ctx *crdt.Context) (crdt.CRDT, error) { func (CrdtTwoEntity) Set(ctx *crdt.Context, state crdt.CRDT) error { return nil } + +type CrdtConfiguredEntity struct { +} + +func NewCrdtConfiguredEntity(id crdt.EntityID) crdt.EntityHandler { + return &CrdtConfiguredEntity{} +} + +func (CrdtConfiguredEntity) HandleCommand(ctx *crdt.CommandContext, name string, msg proto.Message) (*any.Any, error) { + return encoding.MarshalAny(&Response{}) +} + +func (CrdtConfiguredEntity) Default(ctx *crdt.Context) (crdt.CRDT, error) { + return crdt.NewFlag(), nil +} + +func (CrdtConfiguredEntity) Set(ctx *crdt.Context, state crdt.CRDT) error { + return nil +} diff --git a/tck/crdt2/tck_crdt2.pb.go b/tck/crdt2/tck_crdt2.pb.go index 0ae47c9..0e66c19 100644 --- a/tck/crdt2/tck_crdt2.pb.go +++ b/tck/crdt2/tck_crdt2.pb.go @@ -2391,12 +2391,18 @@ var file_tck_crdt2_proto_rawDesc = []byte{ 0x64, 0x65, 0x6c, 0x2e, 0x63, 0x72, 0x64, 0x74, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x74, 0x63, 0x6b, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x63, 0x72, 0x64, 0x74, 0x2e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4d, 0x0a, 0x17, 0x69, 0x6f, 0x2e, 0x63, 0x6c, 0x6f, 0x75, - 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x74, 0x63, 0x6b, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, - 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6c, 0x6f, - 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x69, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, 0x73, 0x75, 0x70, - 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x74, 0x63, 0x6b, 0x2f, 0x63, 0x72, 0x64, 0x74, 0x32, 0x3b, 0x63, - 0x72, 0x64, 0x74, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x61, 0x0a, 0x0e, 0x43, 0x72, 0x64, 0x74, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x64, 0x12, 0x4f, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, + 0x22, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x74, 0x63, 0x6b, + 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x63, 0x72, 0x64, 0x74, 0x2e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x2e, 0x74, 0x63, 0x6b, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x63, 0x72, 0x64, 0x74, 0x2e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4d, 0x0a, 0x17, 0x69, 0x6f, 0x2e, 0x63, + 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x74, 0x63, 0x6b, 0x2e, 0x6d, 0x6f, + 0x64, 0x65, 0x6c, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x69, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, + 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x74, 0x63, 0x6b, 0x2f, 0x63, 0x72, 0x64, 0x74, + 0x32, 0x3b, 0x63, 0x72, 0x64, 0x74, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2484,11 +2490,13 @@ var file_tck_crdt2_proto_depIdxs = []int32{ 2, // 34: cloudstate.tck.model.crdt.CrdtTckModel.Process:input_type -> cloudstate.tck.model.crdt.Request 3, // 35: cloudstate.tck.model.crdt.CrdtTckModel.ProcessStreamed:input_type -> cloudstate.tck.model.crdt.StreamedRequest 2, // 36: cloudstate.tck.model.crdt.CrdtTwo.Call:input_type -> cloudstate.tck.model.crdt.Request - 20, // 37: cloudstate.tck.model.crdt.CrdtTckModel.Process:output_type -> cloudstate.tck.model.crdt.Response - 20, // 38: cloudstate.tck.model.crdt.CrdtTckModel.ProcessStreamed:output_type -> cloudstate.tck.model.crdt.Response - 20, // 39: cloudstate.tck.model.crdt.CrdtTwo.Call:output_type -> cloudstate.tck.model.crdt.Response - 37, // [37:40] is the sub-list for method output_type - 34, // [34:37] is the sub-list for method input_type + 2, // 37: cloudstate.tck.model.crdt.CrdtConfigured.Call:input_type -> cloudstate.tck.model.crdt.Request + 20, // 38: cloudstate.tck.model.crdt.CrdtTckModel.Process:output_type -> cloudstate.tck.model.crdt.Response + 20, // 39: cloudstate.tck.model.crdt.CrdtTckModel.ProcessStreamed:output_type -> cloudstate.tck.model.crdt.Response + 20, // 40: cloudstate.tck.model.crdt.CrdtTwo.Call:output_type -> cloudstate.tck.model.crdt.Response + 20, // 41: cloudstate.tck.model.crdt.CrdtConfigured.Call:output_type -> cloudstate.tck.model.crdt.Response + 38, // [38:42] is the sub-list for method output_type + 34, // [34:38] is the sub-list for method input_type 34, // [34:34] is the sub-list for extension type_name 34, // [34:34] is the sub-list for extension extendee 0, // [0:34] is the sub-list for field type_name @@ -2895,7 +2903,7 @@ func file_tck_crdt2_proto_init() { NumEnums: 2, NumMessages: 29, NumExtensions: 0, - NumServices: 2, + NumServices: 3, }, GoTypes: file_tck_crdt2_proto_goTypes, DependencyIndexes: file_tck_crdt2_proto_depIdxs, diff --git a/tck/crdt2/tck_crdt2_grpc.pb.go b/tck/crdt2/tck_crdt2_grpc.pb.go index 0afc2ca..e319b97 100644 --- a/tck/crdt2/tck_crdt2_grpc.pb.go +++ b/tck/crdt2/tck_crdt2_grpc.pb.go @@ -242,3 +242,86 @@ var _CrdtTwo_serviceDesc = grpc.ServiceDesc{ Streams: []grpc.StreamDesc{}, Metadata: "tck_crdt2.proto", } + +// CrdtConfiguredClient is the client API for CrdtConfigured service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type CrdtConfiguredClient interface { + Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) +} + +type crdtConfiguredClient struct { + cc grpc.ClientConnInterface +} + +func NewCrdtConfiguredClient(cc grpc.ClientConnInterface) CrdtConfiguredClient { + return &crdtConfiguredClient{cc} +} + +func (c *crdtConfiguredClient) Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { + out := new(Response) + err := c.cc.Invoke(ctx, "/cloudstate.tck.model.crdt.CrdtConfigured/Call", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// CrdtConfiguredServer is the server API for CrdtConfigured service. +// All implementations must embed UnimplementedCrdtConfiguredServer +// for forward compatibility +type CrdtConfiguredServer interface { + Call(context.Context, *Request) (*Response, error) + mustEmbedUnimplementedCrdtConfiguredServer() +} + +// UnimplementedCrdtConfiguredServer must be embedded to have forward compatible implementations. +type UnimplementedCrdtConfiguredServer struct { +} + +func (UnimplementedCrdtConfiguredServer) Call(context.Context, *Request) (*Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method Call not implemented") +} +func (UnimplementedCrdtConfiguredServer) mustEmbedUnimplementedCrdtConfiguredServer() {} + +// UnsafeCrdtConfiguredServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to CrdtConfiguredServer will +// result in compilation errors. +type UnsafeCrdtConfiguredServer interface { + mustEmbedUnimplementedCrdtConfiguredServer() +} + +func RegisterCrdtConfiguredServer(s grpc.ServiceRegistrar, srv CrdtConfiguredServer) { + s.RegisterService(&_CrdtConfigured_serviceDesc, srv) +} + +func _CrdtConfigured_Call_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Request) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CrdtConfiguredServer).Call(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cloudstate.tck.model.crdt.CrdtConfigured/Call", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CrdtConfiguredServer).Call(ctx, req.(*Request)) + } + return interceptor(ctx, in, info, handler) +} + +var _CrdtConfigured_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cloudstate.tck.model.crdt.CrdtConfigured", + HandlerType: (*CrdtConfiguredServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Call", + Handler: _CrdtConfigured_Call_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "tck_crdt2.proto", +} diff --git a/tck/eventlogeventing/eventlogeventing.pb.go b/tck/eventlogeventing/eventlogeventing.pb.go index 2522c5e..b5f4c30 100644 --- a/tck/eventlogeventing/eventlogeventing.pb.go +++ b/tck/eventlogeventing/eventlogeventing.pb.go @@ -304,7 +304,6 @@ func (x *JsonEvent) GetMessage() string { // // - Reply: reply with the given message in a `Response`. // - Forward: forward to another service, in place of replying with a `Response`. -// - SideEffect: add a side effect to the current reply, forward, or failure. // type ProcessStep struct { state protoimpl.MessageState diff --git a/tck/eventsourced/eventsourced.pb.go b/tck/eventsourced/eventsourced.pb.go index a436642..7e8e150 100644 --- a/tck/eventsourced/eventsourced.pb.go +++ b/tck/eventsourced/eventsourced.pb.go @@ -589,14 +589,20 @@ var file_eventsourced_proto_rawDesc = []byte{ 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x74, 0x63, 0x6b, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x74, 0x63, 0x6b, 0x2e, 0x6d, - 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x5b, 0x0a, - 0x17, 0x69, 0x6f, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x74, - 0x63, 0x6b, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x69, - 0x6f, 0x2f, 0x67, 0x6f, 0x2d, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x74, 0x63, 0x6b, - 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x64, 0x3b, 0x65, 0x76, - 0x65, 0x6e, 0x74, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x5f, 0x0a, + 0x16, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x64, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x64, 0x12, 0x45, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, + 0x1d, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x74, 0x63, 0x6b, + 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, + 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x74, 0x63, 0x6b, 0x2e, + 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x5b, + 0x0a, 0x17, 0x69, 0x6f, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, + 0x74, 0x63, 0x6b, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x69, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x74, 0x63, + 0x6b, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x64, 0x3b, 0x65, + 0x76, 0x65, 0x6e, 0x74, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -630,10 +636,12 @@ var file_eventsourced_proto_depIdxs = []int32{ 5, // 4: cloudstate.tck.model.RequestAction.fail:type_name -> cloudstate.tck.model.Fail 0, // 5: cloudstate.tck.model.EventSourcedTckModel.Process:input_type -> cloudstate.tck.model.Request 0, // 6: cloudstate.tck.model.EventSourcedTwo.Call:input_type -> cloudstate.tck.model.Request - 6, // 7: cloudstate.tck.model.EventSourcedTckModel.Process:output_type -> cloudstate.tck.model.Response - 6, // 8: cloudstate.tck.model.EventSourcedTwo.Call:output_type -> cloudstate.tck.model.Response - 7, // [7:9] is the sub-list for method output_type - 5, // [5:7] is the sub-list for method input_type + 0, // 7: cloudstate.tck.model.EventSourcedConfigured.Call:input_type -> cloudstate.tck.model.Request + 6, // 8: cloudstate.tck.model.EventSourcedTckModel.Process:output_type -> cloudstate.tck.model.Response + 6, // 9: cloudstate.tck.model.EventSourcedTwo.Call:output_type -> cloudstate.tck.model.Response + 6, // 10: cloudstate.tck.model.EventSourcedConfigured.Call:output_type -> cloudstate.tck.model.Response + 8, // [8:11] is the sub-list for method output_type + 5, // [5:8] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name 5, // [5:5] is the sub-list for extension extendee 0, // [0:5] is the sub-list for field type_name @@ -756,7 +764,7 @@ func file_eventsourced_proto_init() { NumEnums: 0, NumMessages: 8, NumExtensions: 0, - NumServices: 2, + NumServices: 3, }, GoTypes: file_eventsourced_proto_goTypes, DependencyIndexes: file_eventsourced_proto_depIdxs, diff --git a/tck/eventsourced/eventsourced_grpc.pb.go b/tck/eventsourced/eventsourced_grpc.pb.go index 03fa2bc..d03acd4 100644 --- a/tck/eventsourced/eventsourced_grpc.pb.go +++ b/tck/eventsourced/eventsourced_grpc.pb.go @@ -178,3 +178,87 @@ var _EventSourcedTwo_serviceDesc = grpc.ServiceDesc{ Streams: []grpc.StreamDesc{}, Metadata: "eventsourced.proto", } + +// EventSourcedConfiguredClient is the client API for EventSourcedConfigured service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type EventSourcedConfiguredClient interface { + Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) +} + +type eventSourcedConfiguredClient struct { + cc grpc.ClientConnInterface +} + +func NewEventSourcedConfiguredClient(cc grpc.ClientConnInterface) EventSourcedConfiguredClient { + return &eventSourcedConfiguredClient{cc} +} + +func (c *eventSourcedConfiguredClient) Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { + out := new(Response) + err := c.cc.Invoke(ctx, "/cloudstate.tck.model.EventSourcedConfigured/Call", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// EventSourcedConfiguredServer is the server API for EventSourcedConfigured service. +// All implementations must embed UnimplementedEventSourcedConfiguredServer +// for forward compatibility +type EventSourcedConfiguredServer interface { + Call(context.Context, *Request) (*Response, error) + mustEmbedUnimplementedEventSourcedConfiguredServer() +} + +// UnimplementedEventSourcedConfiguredServer must be embedded to have forward compatible implementations. +type UnimplementedEventSourcedConfiguredServer struct { +} + +func (UnimplementedEventSourcedConfiguredServer) Call(context.Context, *Request) (*Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method Call not implemented") +} +func (UnimplementedEventSourcedConfiguredServer) mustEmbedUnimplementedEventSourcedConfiguredServer() { +} + +// UnsafeEventSourcedConfiguredServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to EventSourcedConfiguredServer will +// result in compilation errors. +type UnsafeEventSourcedConfiguredServer interface { + mustEmbedUnimplementedEventSourcedConfiguredServer() +} + +func RegisterEventSourcedConfiguredServer(s grpc.ServiceRegistrar, srv EventSourcedConfiguredServer) { + s.RegisterService(&_EventSourcedConfigured_serviceDesc, srv) +} + +func _EventSourcedConfigured_Call_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Request) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EventSourcedConfiguredServer).Call(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cloudstate.tck.model.EventSourcedConfigured/Call", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EventSourcedConfiguredServer).Call(ctx, req.(*Request)) + } + return interceptor(ctx, in, info, handler) +} + +var _EventSourcedConfigured_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cloudstate.tck.model.EventSourcedConfigured", + HandlerType: (*EventSourcedConfiguredServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Call", + Handler: _EventSourcedConfigured_Call_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "eventsourced.proto", +} diff --git a/tck/eventsourced/model.go b/tck/eventsourced/model.go index 8dc5d96..dc7302b 100644 --- a/tck/eventsourced/model.go +++ b/tck/eventsourced/model.go @@ -109,3 +109,18 @@ func (m *TestModelTwo) HandleEvent(ctx *eventsourced.Context, event interface{}) func NewTestModelTwo(id eventsourced.EntityID) eventsourced.EntityHandler { return &TestModelTwo{} } + +type EventSourcedConfiguredEntity struct { +} + +func NewEventSourcedConfiguredEntity(id eventsourced.EntityID) eventsourced.EntityHandler { + return &EventSourcedConfiguredEntity{} +} + +func (e *EventSourcedConfiguredEntity) HandleCommand(ctx *eventsourced.Context, name string, cmd proto.Message) (reply proto.Message, err error) { + return &Response{}, err +} + +func (e *EventSourcedConfiguredEntity) HandleEvent(ctx *eventsourced.Context, event interface{}) error { + return nil +} diff --git a/tck/value/model.go b/tck/value/model.go index fba87d1..810052e 100644 --- a/tck/value/model.go +++ b/tck/value/model.go @@ -98,3 +98,18 @@ func (e *ValueEntityTckModelEntityTwo) HandleCommand(ctx *value.Context, name st func (e *ValueEntityTckModelEntityTwo) HandleState(ctx *value.Context, state *any.Any) error { return nil } + +type ValueEntityConfiguredEntity string + +func NewValueEntityConfiguredEntity(id value.EntityID) value.EntityHandler { + r := ValueEntityConfiguredEntity("state") + return &r +} + +func (v *ValueEntityConfiguredEntity) HandleCommand(ctx *value.Context, name string, msg proto.Message) (*any.Any, error) { + return encoding.MarshalAny(&Response{}) +} + +func (v *ValueEntityConfiguredEntity) HandleState(ctx *value.Context, state *any.Any) error { + return nil +} diff --git a/tck/value/tck_valueentity.pb.go b/tck/value/tck_valueentity.pb.go index 42ad681..79134d8 100644 --- a/tck/value/tck_valueentity.pb.go +++ b/tck/value/tck_valueentity.pb.go @@ -658,14 +658,21 @@ var file_tck_valueentity_proto_rawDesc = []byte{ 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x74, 0x63, 0x6b, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x65, 0x0a, 0x23, 0x69, 0x6f, 0x2e, 0x63, 0x6c, - 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x74, 0x63, 0x6b, 0x2e, 0x6d, 0x6f, 0x64, - 0x65, 0x6c, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5a, 0x3e, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x69, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, 0x73, 0x75, 0x70, 0x70, 0x6f, - 0x72, 0x74, 0x2f, 0x74, 0x63, 0x6b, 0x2f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x65, 0x6e, 0x74, 0x69, - 0x74, 0x79, 0x3b, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x76, 0x0a, 0x15, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x64, + 0x12, 0x5d, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x29, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x74, 0x63, 0x6b, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x2e, 0x74, 0x63, 0x6b, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, + 0x65, 0x0a, 0x23, 0x69, 0x6f, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x2e, 0x74, 0x63, 0x6b, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x73, 0x74, 0x61, 0x74, 0x65, 0x69, 0x6f, 0x2f, + 0x67, 0x6f, 0x2d, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x74, 0x63, 0x6b, 0x2f, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x3b, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -701,10 +708,12 @@ var file_tck_valueentity_proto_depIdxs = []int32{ 6, // 5: cloudstate.tck.model.valueentity.RequestAction.fail:type_name -> cloudstate.tck.model.valueentity.Fail 0, // 6: cloudstate.tck.model.valueentity.ValueEntityTckModel.Process:input_type -> cloudstate.tck.model.valueentity.Request 0, // 7: cloudstate.tck.model.valueentity.ValueEntityTwo.Call:input_type -> cloudstate.tck.model.valueentity.Request - 7, // 8: cloudstate.tck.model.valueentity.ValueEntityTckModel.Process:output_type -> cloudstate.tck.model.valueentity.Response - 7, // 9: cloudstate.tck.model.valueentity.ValueEntityTwo.Call:output_type -> cloudstate.tck.model.valueentity.Response - 8, // [8:10] is the sub-list for method output_type - 6, // [6:8] is the sub-list for method input_type + 0, // 8: cloudstate.tck.model.valueentity.ValueEntityConfigured.Call:input_type -> cloudstate.tck.model.valueentity.Request + 7, // 9: cloudstate.tck.model.valueentity.ValueEntityTckModel.Process:output_type -> cloudstate.tck.model.valueentity.Response + 7, // 10: cloudstate.tck.model.valueentity.ValueEntityTwo.Call:output_type -> cloudstate.tck.model.valueentity.Response + 7, // 11: cloudstate.tck.model.valueentity.ValueEntityConfigured.Call:output_type -> cloudstate.tck.model.valueentity.Response + 9, // [9:12] is the sub-list for method output_type + 6, // [6:9] is the sub-list for method input_type 6, // [6:6] is the sub-list for extension type_name 6, // [6:6] is the sub-list for extension extendee 0, // [0:6] is the sub-list for field type_name @@ -840,7 +849,7 @@ func file_tck_valueentity_proto_init() { NumEnums: 0, NumMessages: 9, NumExtensions: 0, - NumServices: 2, + NumServices: 3, }, GoTypes: file_tck_valueentity_proto_goTypes, DependencyIndexes: file_tck_valueentity_proto_depIdxs, diff --git a/tck/value/tck_valueentity_grpc.pb.go b/tck/value/tck_valueentity_grpc.pb.go index c8e50b4..48a669e 100644 --- a/tck/value/tck_valueentity_grpc.pb.go +++ b/tck/value/tck_valueentity_grpc.pb.go @@ -178,3 +178,86 @@ var _ValueEntityTwo_serviceDesc = grpc.ServiceDesc{ Streams: []grpc.StreamDesc{}, Metadata: "tck_valueentity.proto", } + +// ValueEntityConfiguredClient is the client API for ValueEntityConfigured service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type ValueEntityConfiguredClient interface { + Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) +} + +type valueEntityConfiguredClient struct { + cc grpc.ClientConnInterface +} + +func NewValueEntityConfiguredClient(cc grpc.ClientConnInterface) ValueEntityConfiguredClient { + return &valueEntityConfiguredClient{cc} +} + +func (c *valueEntityConfiguredClient) Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { + out := new(Response) + err := c.cc.Invoke(ctx, "/cloudstate.tck.model.valueentity.ValueEntityConfigured/Call", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ValueEntityConfiguredServer is the server API for ValueEntityConfigured service. +// All implementations must embed UnimplementedValueEntityConfiguredServer +// for forward compatibility +type ValueEntityConfiguredServer interface { + Call(context.Context, *Request) (*Response, error) + mustEmbedUnimplementedValueEntityConfiguredServer() +} + +// UnimplementedValueEntityConfiguredServer must be embedded to have forward compatible implementations. +type UnimplementedValueEntityConfiguredServer struct { +} + +func (UnimplementedValueEntityConfiguredServer) Call(context.Context, *Request) (*Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method Call not implemented") +} +func (UnimplementedValueEntityConfiguredServer) mustEmbedUnimplementedValueEntityConfiguredServer() {} + +// UnsafeValueEntityConfiguredServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ValueEntityConfiguredServer will +// result in compilation errors. +type UnsafeValueEntityConfiguredServer interface { + mustEmbedUnimplementedValueEntityConfiguredServer() +} + +func RegisterValueEntityConfiguredServer(s grpc.ServiceRegistrar, srv ValueEntityConfiguredServer) { + s.RegisterService(&_ValueEntityConfigured_serviceDesc, srv) +} + +func _ValueEntityConfigured_Call_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Request) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ValueEntityConfiguredServer).Call(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cloudstate.tck.model.valueentity.ValueEntityConfigured/Call", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ValueEntityConfiguredServer).Call(ctx, req.(*Request)) + } + return interceptor(ctx, in, info, handler) +} + +var _ValueEntityConfigured_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cloudstate.tck.model.valueentity.ValueEntityConfigured", + HandlerType: (*ValueEntityConfiguredServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Call", + Handler: _ValueEntityConfigured_Call_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "tck_valueentity.proto", +}