Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

WIP-CRUD on top of Event Sourcing #220

Merged
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
6d3b2c1
Issue-197: add npm task for preparing node-support to be able to buil…
ralphlaude Feb 22, 2020
0fbd706
Merge remote-tracking branch 'upstream/master'
ralphlaude Feb 24, 2020
27d22ff
Merge remote-tracking branch 'upstream/master'
ralphlaude Feb 27, 2020
2a32aa1
Merge remote-tracking branch 'upstream/master'
ralphlaude Mar 12, 2020
579d1c4
Merge remote-tracking branch 'upstream/master'
ralphlaude Mar 16, 2020
8014961
Merge remote-tracking branch 'upstream/master'
ralphlaude Mar 23, 2020
91f3333
Merge remote-tracking branch 'upstream/master'
ralphlaude Mar 25, 2020
38327d3
Proposal for CRUD on top of Event Sourcing
ralphlaude Mar 30, 2020
6cc25fe
Proposal for CRUD on top of Event Sourcing; Comment code handling events
ralphlaude Mar 30, 2020
9a7a8bf
rollback changes in the proxy and add proto file for the CRUD domain
ralphlaude Mar 30, 2020
db2e4a8
Add CrudEntity annotation. Add registration for CrudEntity in CloudSt…
ralphlaude Mar 31, 2020
8aa1e97
Merge remote-tracking branch 'upstream/master'
ralphlaude Apr 2, 2020
2374b7b
change CrudEntity annotation. Change registration for CrudEntity in C…
ralphlaude Apr 14, 2020
82c2377
Merge remote-tracking branch 'upstream/master'
ralphlaude Apr 16, 2020
1f741d9
Merge remote-tracking branch 'upstream/master'
ralphlaude Apr 21, 2020
ca6b416
Merge remote-tracking branch 'upstream/master'
ralphlaude Apr 23, 2020
92effcd
Merge remote-tracking branch 'upstream/master'
ralphlaude Apr 24, 2020
473d682
Merge remote-tracking branch 'upstream/master'
ralphlaude Apr 24, 2020
6e23140
Merge remote-tracking branch 'upstream/master'
ralphlaude Apr 26, 2020
3664944
Merge remote-tracking branch 'upstream/master'
ralphlaude Apr 28, 2020
c9cc5f6
Merge branch 'master' into wip-crud-on-top-of-event-sourcing
ralphlaude Apr 28, 2020
cee69f1
Merge remote-tracking branch 'upstream/master'
ralphlaude May 1, 2020
8e951e4
Merge remote-tracking branch 'upstream/master'
ralphlaude May 4, 2020
170bb0c
Merge branch 'master' into wip-crud-on-top-of-event-sourcing
ralphlaude May 4, 2020
78b7840
Initial version for the CRUD protocol and the implementation
ralphlaude May 14, 2020
012c1e3
remove unused import
ralphlaude May 14, 2020
5647e15
Merge remote-tracking branch 'upstream/master'
ralphlaude May 15, 2020
dc810c4
Add comments and change the proto definition
ralphlaude May 15, 2020
078517f
Change the protocol to have one reply type for all operations and imp…
ralphlaude May 18, 2020
5e8ec79
Merge remote-tracking branch 'upstream/master'
ralphlaude May 21, 2020
da4a331
add crud command type as proto field option and extend the user funct…
ralphlaude May 24, 2020
78345f8
add some documentation and do some small refactoring
ralphlaude May 25, 2020
d1bdbb1
add java doc for crud protocol. extend the shopping cart example. ref…
ralphlaude May 26, 2020
d9a5dbd
Merge remote-tracking branch 'upstream/master'
ralphlaude May 27, 2020
ab73109
Merge branch 'master' into wip-crud-on-top-of-event-sourcing
ralphlaude May 27, 2020
e906657
Merge branch 'prototype-crud-on-event-sourcing' into wip-crud-on-top-…
ralphlaude May 27, 2020
344d8d9
Documents the protocol and add new grpc type for command type. implem…
ralphlaude Jun 9, 2020
cda633a
Merge branch 'prototype-crud-on-event-sourcing' into wip-crud-on-top-…
ralphlaude Jun 9, 2020
87d1c4f
Merge branch 'master' into wip-crud-on-top-of-event-sourcing
ralphlaude Jul 14, 2020
d0215aa
Provide a definition of the protocol with snapshotting capabilities a…
ralphlaude Jul 14, 2020
9f72587
wording fixed
ralphlaude Jul 14, 2020
866941d
add sample for crud shopping cart and rollback the sample shopping ca…
ralphlaude Jul 26, 2020
6e997f2
remove old crud shopping cart
ralphlaude Jul 26, 2020
9c9e02b
add StreamFailed in the presstart method
ralphlaude Jul 27, 2020
164a650
add tests for crud entity
ralphlaude Jul 27, 2020
9a3cf53
removed obsolete classes
ralphlaude Jul 27, 2020
c5de37d
add annotations for update and delete handlers
ralphlaude Jul 28, 2020
0979a9e
fixed scala format
ralphlaude Jul 28, 2020
5169003
fixed unit value
ralphlaude Jul 28, 2020
b93a3c0
Merge branch 'master' into wip-crud-on-top-of-event-sourcing
ralphlaude Jul 28, 2020
1321d1e
fixed protobuf attribute index and fixed crud init state handling
ralphlaude Jul 29, 2020
c6e162a
fixed shopping cart entity
ralphlaude Jul 30, 2020
0675b17
call command handler only when the command was successful. Make the C…
ralphlaude Aug 26, 2020
1fd017d
Merge branch 'master' into wip-crud-on-top-of-event-sourcing
ralphlaude Aug 26, 2020
928933c
fixed test
ralphlaude Aug 26, 2020
2310fc9
add native CRUD support with slick and integrate the in memory CRUD s…
ralphlaude Sep 7, 2020
919756d
modified markdown
ralphlaude Sep 7, 2020
dd2e4c8
add generic to command context and entity handler
ralphlaude Sep 7, 2020
bbd5e53
remove the use of sequence number in the GRPC CRUD protocol
ralphlaude Sep 7, 2020
99f8ffc
remove event sourced in memory snapshot store. adapt log for in memor…
ralphlaude Sep 7, 2020
8692f57
first version for checking null on updateEntity
ralphlaude Sep 7, 2020
18ce9c8
add comments
ralphlaude Sep 7, 2020
209648d
add exception handling based on the one in event sourced
ralphlaude Sep 9, 2020
44175e0
add new lines
ralphlaude Sep 9, 2020
b866e71
rewrite crud protocol by using oly command handler and passing the st…
ralphlaude Sep 14, 2020
2731570
change entity initialization
ralphlaude Sep 15, 2020
46b54fc
change entity initialization and adapt annotation based support test
ralphlaude Sep 15, 2020
7ec4ab5
change test name
ralphlaude Sep 15, 2020
d076e86
ignore CRUD entity test
ralphlaude Sep 15, 2020
b05f7aa
remove subsequent invocation checking which is not needed
ralphlaude Sep 16, 2020
11135d7
adapt the init case for the entity
ralphlaude Sep 17, 2020
cb282ad
deal with empty schema in the config
ralphlaude Sep 17, 2020
863dfe3
add comment for already initialized entity
ralphlaude Sep 18, 2020
e511b4b
integrate native crud support in postgres module
ralphlaude Sep 18, 2020
3bc45a0
save CRUD state as byte array
ralphlaude Sep 18, 2020
93a5962
fixed map on slick dbioaction
ralphlaude Sep 18, 2020
dd19ed1
change actor name
ralphlaude Sep 20, 2020
e84d4e6
add infra for CRUD tests in testkit. add exception handling test for …
ralphlaude Sep 22, 2020
6243e4d
Merge branch 'master' into wip-crud-on-top-of-event-sourcing
ralphlaude Sep 22, 2020
624afbf
fixed conflicts and compile errors when merging master
ralphlaude Sep 22, 2020
968c332
fixed format error
ralphlaude Sep 22, 2020
29cdd47
add test for the crud java support
ralphlaude Sep 23, 2020
5cf66b7
remove comments and logs
ralphlaude Sep 23, 2020
bb98d71
changed java 11 for crud sample and fixed conflicting package name
ralphlaude Sep 23, 2020
6a2cd86
Merge branch 'master' into wip-crud-on-top-of-event-sourcing
ralphlaude Sep 25, 2020
8acd3c9
remove concurrency enforcer
ralphlaude Sep 26, 2020
5a97b74
disabled CRUD native support for now
ralphlaude Sep 26, 2020
1b163b3
Add CRUD to expected protocols in TCK
pvlugter Sep 29, 2020
821fd4c
Add default value for cloudstate.proxy.postgres.schema setting
pvlugter Sep 29, 2020
5d9a193
enabled CRUD for the proxy and add readiness-checks
ralphlaude Sep 29, 2020
0248e53
add hikari connection pool properties
ralphlaude Sep 30, 2020
d8f2e9f
fixed protobuf any deserialization
ralphlaude Sep 30, 2020
4c90c02
Merge branch 'master' into wip-crud-on-top-of-event-sourcing
ralphlaude Oct 3, 2020
353b41c
add TCK test for CRUD initial version
ralphlaude Oct 3, 2020
47f7cd3
add TCK test for CRUD and refactoring jdbc store factory
ralphlaude Oct 3, 2020
735257c
Merge remote-tracking branch 'origin/wip-crud-on-top-of-event-sourcin…
ralphlaude Oct 16, 2020
e7ae59c
removed class
ralphlaude Oct 16, 2020
41f189a
Merge branch 'master' into wip-crud-on-top-of-event-sourcing
ralphlaude Oct 16, 2020
3f9789e
add metadata
ralphlaude Oct 16, 2020
eac2e7f
add table creation readiness in native image
ralphlaude Oct 17, 2020
35e0005
rename CRUD to Value Entity
ralphlaude Oct 20, 2020
f820f7f
rename CRUD to Value Entity
ralphlaude Oct 20, 2020
f21b7d0
rename CRUD to Value Entity follow up (crud jdbc configuration to val…
ralphlaude Oct 21, 2020
f65553c
add entity exceptions factory class. extract grpc entity message crea…
ralphlaude Oct 23, 2020
dd30efb
Merge branch 'master' into wip-crud-on-top-of-event-sourcing
ralphlaude Oct 29, 2020
517ee37
integrate tests for entity in circleci
ralphlaude Oct 29, 2020
d4b2493
integrate tests for entity in circleci by building the entity image
ralphlaude Oct 29, 2020
a6bc7d9
integrate tests for entity in circleci by saving the entity image in …
ralphlaude Oct 29, 2020
375f9f9
add jdbc config tests
ralphlaude Oct 29, 2020
a578d6b
Merge branch 'master' into pr/220
pvlugter Nov 1, 2020
87dbd80
Update entity smoke test script
pvlugter Nov 2, 2020
65e5fc8
Fix entity delete in smoke test script
pvlugter Nov 2, 2020
2f6ba27
Add native-image configuration for value entity table
pvlugter Nov 2, 2020
8f1835a
Reduce value entity connection pool size
pvlugter Nov 2, 2020
62f0500
exclude slick dependency from other core persistence module.
ralphlaude Nov 2, 2020
f7e27aa
renaming value entity to entity in the java support, the proxy, the t…
ralphlaude Nov 6, 2020
a2bf57c
fixed native image configuration for value entity
ralphlaude Nov 7, 2020
469edab
write test for properly accessing the state after passivation
ralphlaude Nov 9, 2020
403aed0
fixed grammar
ralphlaude Nov 9, 2020
10c931e
Merge branch 'master' into wip-crud-on-top-of-event-sourcing
ralphlaude Nov 9, 2020
c915048
merge master and refactoring
ralphlaude Nov 9, 2020
5bf6a12
combined readiness checks for eventsourced and value entity
ralphlaude Nov 9, 2020
937084e
fixed readiness check
ralphlaude Nov 9, 2020
5545e6d
removed dedicated readiness check for value entity
ralphlaude Nov 9, 2020
5856394
fixed grammar, remove left crud names and fixed code
ralphlaude Nov 10, 2020
427b538
Merge branch 'master' into pr/220
pvlugter Nov 11, 2020
18cde26
Dynamically create value entity stores
pvlugter Nov 11, 2020
dc786ca
adapt the store-api to able to persist the tpye url of the entity
ralphlaude Nov 11, 2020
340325d
add comment for explaining duplicate shoppingcart.proto
ralphlaude Nov 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@

import com.typesafe.config.Config;
import com.google.protobuf.Descriptors;
import io.cloudstate.javasupport.crud.CrudEntity;
import io.cloudstate.javasupport.crdt.CrdtEntity;
import io.cloudstate.javasupport.crdt.CrdtEntityFactory;
import io.cloudstate.javasupport.crud.CrudEntityFactory;
import io.cloudstate.javasupport.eventsourced.EventSourcedEntity;
import io.cloudstate.javasupport.eventsourced.EventSourcedEntityFactory;
import io.cloudstate.javasupport.impl.AnySupport;
import io.cloudstate.javasupport.impl.crdt.AnnotationBasedCrdtSupport;
import io.cloudstate.javasupport.impl.crdt.CrdtStatefulService;
import io.cloudstate.javasupport.impl.crud.AnnotationBasedCrudSupport;
import io.cloudstate.javasupport.impl.crud.CrudStatefulService;
import io.cloudstate.javasupport.impl.eventsourced.AnnotationBasedEventSourcedSupport;
import io.cloudstate.javasupport.impl.eventsourced.EventSourcedStatefulService;

Expand Down Expand Up @@ -137,7 +141,7 @@ public CloudState registerEventSourcedEntity(
}

/**
* Register an event sourced entity factor.
* Register an event sourced entity factory.
*
* <p>This is a low level API intended for custom (eg, non reflection based) mechanisms for
* implementing the entity.
Expand Down Expand Up @@ -205,7 +209,7 @@ public CloudState registerCrdtEntity(
}

/**
* Register an CRDt entity factory.
* Register an CRDT entity factory.
*
* <p>This is a low level API intended for custom (eg, non reflection based) mechanisms for
* implementing the entity.
Expand All @@ -227,6 +231,86 @@ public CloudState registerCrdtEntity(
return this;
}

/**
* Register an annotated CRUD entity.
*
* <p>The entity class must be annotated with {@link io.cloudstate.javasupport.crud.CrudEntity}.
*
* @param entityClass The entity class.
* @param descriptor The descriptor for the service that this entity implements.
* @param additionalDescriptors Any additional descriptors that should be used to look up protobuf
* types when needed.
* @return This stateful service builder.
*/
public CloudState registerCrudEntity(
Class<?> entityClass,
Descriptors.ServiceDescriptor descriptor,
Descriptors.FileDescriptor... additionalDescriptors) {

CrudEntity entity = entityClass.getAnnotation(CrudEntity.class);
if (entity == null) {
throw new IllegalArgumentException(
entityClass + " does not declare an " + CrudEntity.class + " annotation!");
}

final String persistenceId;
final int snapshotEvery;
if (entity.persistenceId().isEmpty()) {
persistenceId = entityClass.getSimpleName();
snapshotEvery = 0; // Default
} else {
persistenceId = entity.persistenceId();
snapshotEvery = entity.snapshotEvery();
}

final AnySupport anySupport = newAnySupport(additionalDescriptors);

services.put(
descriptor.getFullName(),
new CrudStatefulService(
new AnnotationBasedCrudSupport(entityClass, anySupport, descriptor),
descriptor,
anySupport,
persistenceId,
snapshotEvery));

return this;
}

/**
* Register an CRUD entity factory.
*
* <p>This is a low level API intended for custom (eg, non reflection based) mechanisms for
* implementing the entity.
*
* @param factory The CRUD factory.
* @param descriptor The descriptor for the service that this entity implements.
* @param persistenceId The persistence id for this entity.
* @param snapshotEvery Specifies how snapshots of the entity state should be made: Zero means use
* default from configuration file. (Default) Any negative value means never snapshot. Any
* positive value means snapshot at-or-after that number of events.
* @param additionalDescriptors Any additional descriptors that should be used to look up protobuf
* types when needed.
* @return This stateful service builder.
*/
public CloudState registerCrudEntity(
CrudEntityFactory factory,
Descriptors.ServiceDescriptor descriptor,
String persistenceId,
int snapshotEvery,
Descriptors.FileDescriptor... additionalDescriptors) {
services.put(
descriptor.getFullName(),
new CrudStatefulService(
factory,
descriptor,
newAnySupport(additionalDescriptors),
persistenceId,
snapshotEvery));

return this;
}

/**
* Starts a server with the configured entities.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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 io.cloudstate.javasupport.crud;

import io.cloudstate.javasupport.ClientActionContext;
import io.cloudstate.javasupport.EffectContext;

/**
* An CRUD command context.
ralphlaude marked this conversation as resolved.
Show resolved Hide resolved
*
* <p>Methods annotated with {@link CommandHandler} may take this is a parameter. It allows updating
* or deleting the entity state in response to a command, along with forwarding the result to other
* entities, and performing side effects on other entities.
*/
public interface CommandContext extends CrudContext, ClientActionContext, EffectContext {
/**
* The current sequence number of state in this entity.
*
* @return The current sequence number.
*/
long sequenceNumber();

/**
* The name of the command being executed.
*
* @return The name of the command.
*/
String commandName();

/**
* The id of the command being executed.
*
* @return The id of the command.
*/
long commandId();

/**
* Update the entity with the new state. The state will be persisted.
*
* @param state The state to persist.
*/
void update(Object state);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ralphlaude Perhaps updateEntity? Also, what happens if someone does:

ctx.deleteEntity() followed by ctx.update(…)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ralphlaude Should it be possible to update(null)? Also, what happens if the type of the entity denoted by state has the wrong type? Is it possible to have a type associated with the CommandContext?

Copy link
Contributor Author

@ralphlaude ralphlaude Aug 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viktorklang

Also, what happens if someone does: ctx.deleteEntity() followed by ctx.update(…)?

the way it is implemented now the User Function will updated accordingly and the CRUD entity will apply only the last command, which is update in this case.
The actual implementation only applies the last client action to the CRUD entity.
One solution would be to collect all client actions and update the User Function accordingly and also apply them to the CRUD entity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viktorklang

Should it be possible to update(null)? Also, what happens if the type of the entity denoted by state has the wrong type? Is it possible to have a type associated with the CommandContext?

i don't think it should be possible to update(null) and it should be prevented with a kind of RuntimeException.

If state has the wrong type the UpdateStateHandler will fail:


Associating the CommandContext with the a type, like this CommandContext<EntityTpye>, sounds good and i will investigate that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viktorklang,

Also, what happens if someone does: ctx.deleteEntity() followed by ctx.updateEntity(…)?

in the actual implementation the last CRUD action will win and will be applied. In this case it is updateEntity. I am really sure about the most valuable options. I think an valuable option would be to allow the CommandContext to collect all CRUD actions and applied them all instead of ignoring some CRUD actions. What do you think?


/** Delete the entity. */
void delete();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ralphlaude Perhaps this should instead be called something like deleteEntity() since we are not deleting the context itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viktorklang agreed deleteEntity and updateEntity are a better and concise names. it will be changed

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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 io.cloudstate.javasupport.crud;

import io.cloudstate.javasupport.impl.CloudStateAnnotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Marks a method as a command handler.
*
* <p>This method will be invoked whenever the service call with name that matches this command
* handlers name is invoked.
*
* <p>The method may take the command object as a parameter, its type must match the gRPC service
* input type.
*
* <p>The return type of the method must match the gRPC services output type.
*
* <p>The method may also take a {@link CommandContext}, and/or a {@link
* io.cloudstate.javasupport.EntityId} annotated {@link String} parameter.
*/
@CloudStateAnnotation
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface CommandHandler {

/**
* The name of the command to handle.
*
* <p>If not specified, the name of the method will be used as the command name, with the first
* letter capitalized to match the gRPC convention of capitalizing rpc method names.
*
* @return The command name.
*/
String name() default "";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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 io.cloudstate.javasupport.crud;

import io.cloudstate.javasupport.EntityContext;

/** Root context for all CRUD contexts. */
public interface CrudContext extends EntityContext {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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 io.cloudstate.javasupport.crud;

import io.cloudstate.javasupport.impl.CloudStateAnnotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/** An CRUD entity. */
ralphlaude marked this conversation as resolved.
Show resolved Hide resolved
@CloudStateAnnotation
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface CrudEntity {
/**
* The name of the persistence id.
*
* <p>If not specified, defaults to the entities unqualified classname. It's strongly recommended
* that you specify it explicitly.
*/
String persistenceId() default "";

/**
* Specifies how snapshots of the entity state should be made: Zero means use default from
* configuration file. (Default) Any negative value means never snapshot. Any positive value means
* snapshot at-or-after that number of events.
*/
int snapshotEvery() default 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +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 io.cloudstate.javasupport.crud;

/**
* Creation context for {@link CrudEntity} annotated entities.
*
* <p>This may be accepted as an argument to the constructor of an CRUD entity.
ralphlaude marked this conversation as resolved.
Show resolved Hide resolved
*/
public interface CrudEntityCreationContext extends CrudContext {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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 io.cloudstate.javasupport.crud;

import io.cloudstate.javasupport.eventsourced.CommandHandler;
import io.cloudstate.javasupport.eventsourced.EventHandler;

/**
* Low level interface for handling commands on an CRUD entity.
ralphlaude marked this conversation as resolved.
Show resolved Hide resolved
*
* <p>Generally, this should not be needed, instead, a class annotated with the {@link
* CommandHandler} and similar annotations should be used.
*/
public interface CrudEntityFactory {
/**
* Create an entity handler for the given context.
*
* @param context The context.
* @return The handler for the given context.
*/
CrudEntityHandler create(CrudContext context);
}
Loading