Interface KeyValueEntity.Effect.OnSuccessBuilder<S>
- Type Parameters:
S- The type of the state for this entity
- Enclosing interface:
KeyValueEntity.Effect<T>
updateState or
deleteEntity. This allows you to both modify the entity and send a response to the
caller in a single effect.-
Method Summary
Modifier and TypeMethodDescriptionexpireAfter(Duration ttl) Sets a time-to-live for this entity.<T> KeyValueEntity.Effect<T> Sends a reply message to the caller after the state operation (update or delete) completes successfully.<T> KeyValueEntity.Effect<T> thenReply(T message) Sends a reply message to the caller after the state operation (update or delete) completes successfully.<T> KeyValueEntity.Effect<T> Sends a reply message with additional metadata to the caller after the state operation completes successfully.Change the replication filter for this entity, combined with updating state.
-
Method Details
-
thenReply
Sends a reply message to the caller after the state operation (update or delete) completes successfully. This is typically used to confirm the operation and return the new state or operation result.- Type Parameters:
T- the type of the reply message- Parameters:
message- the payload of the reply message- Returns:
- an effect that will perform the state operation and then send the reply
-
thenReply
Sends a reply message with additional metadata to the caller after the state operation completes successfully.- Type Parameters:
T- the type of the reply message- Parameters:
message- the payload of the reply messagemetadata- additional metadata to include with the reply- Returns:
- an effect that will perform the state operation and then send the reply
-
thenReply
Sends a reply message to the caller after the state operation (update or delete) completes successfully. The reply is computed by the given supplier, which is called after the state operation succeeds. This is useful for performing side effects (such as publishing notifications) that should only happen after a successful persist.- Type Parameters:
T- the type of the reply message- Parameters:
replySupplier- a supplier that produces the reply message- Returns:
- an effect that will perform the state operation and then send the reply
-
updateReplicationFilter
Change the replication filter for this entity, combined with updating state.State us by default replicated to all regions that have been enabled for the service. This method allows you to control which regions participate in the replication for this specific entity instance. This is useful for regulatory reasons or as cost optimization.
This effect can be combined with updating the state. For example, you can update the state and then update the replication filter in the same command handler.
The replication filter can only be updated from the primary region of the entity, or the entity will become the primary if using the request-region primary selection strategy. The filter is durable for the specific entity instance and can be changed without deploying a new version.
The region where the update is made (the self region) is automatically included in the replication filter. The changes are additive, meaning that if you first update the filter to include one region and then later make another update to include a different region from the same entity, both regions are included.
- Parameters:
filter- the replication filter defining which regions to include or exclude- Returns:
- an effect builder for chaining additional operations
-
expireAfter
Sets a time-to-live for this entity. The entity will be automatically deleted once the given duration has elapsed and no further update was done.As soon as a new update is done, the TTL is no longer applied. To keep the TTL in effect after subsequent updates, each update will have to be marked with
expireAfter.- Parameters:
ttl- the duration from the time of this write after which the entity will be deleted- Returns:
- an effect builder for chaining additional operations
-