public class Stand
extends java.lang.Object
implements java.lang.AutoCloseable
QueryService
and
SubscriptionService
with a Read-side of
a Bounded Context.
Each BoundedContext
contains only one
instance of Stand
.
The Stand
is responsible for obtaining results of
queries sent by
the QueryService
.
The Stand
also manages creation of subscriptions, their
activation, and
delivering updates to the subscribers when requested by
the SubscriptionService.
Modifier and Type | Class and Description |
---|---|
static class |
Stand.Builder |
Modifier and Type | Method and Description |
---|---|
void |
activate(io.spine.client.Subscription subscription,
SubscriptionCallback callback,
io.grpc.stub.StreamObserver<io.spine.core.Response> responseObserver)
Activates the subscription created via
subscribe() method. |
void |
cancel(io.spine.client.Subscription subscription,
io.grpc.stub.StreamObserver<io.spine.core.Response> responseObserver)
Cancels the
Subscription . |
void |
close()
Closes the
Stand performing necessary cleanups. |
Listener<EventEnvelope> |
eventListener()
Obtains the bus listener which propagates all events and state updates to subscriptions.
|
void |
execute(io.spine.client.Query query,
io.grpc.stub.StreamObserver<io.spine.client.QueryResponse> responseObserver)
Reads a particular set of items from the read-side of the application and
feed the result into an instance.
|
com.google.common.collect.ImmutableSet<io.spine.type.TypeUrl> |
exposedAggregateTypes()
Reads all
Aggregate entity types
exposed for reading by this instance of Stand . |
com.google.common.collect.ImmutableSet<io.spine.type.TypeUrl> |
exposedEventTypes()
Reads all event types produced by the repositories associated with this
Stand . |
com.google.common.collect.ImmutableSet<io.spine.type.TypeUrl> |
exposedTypes()
Reads all
Entity types exposed for reading by this instance of Stand . |
static Stand.Builder |
newBuilder() |
void |
registerTypeSupplier(EventProducer producer)
Registers the passed
EventProducer as the event type supplier. |
void |
registerTypeSupplier(Repository<?,?> repository)
Registers the passed
Repository as an entity/event type supplier. |
void |
subscribe(io.spine.client.Subscription subscription)
Registers this inactive subscription is this
Stand . |
void |
subscribe(io.spine.client.Topic topic,
io.grpc.stub.StreamObserver<io.spine.client.Subscription> responseObserver)
Creates a subscription for the passed topic.
|
public static Stand.Builder newBuilder()
public void subscribe(io.spine.client.Topic topic, io.grpc.stub.StreamObserver<io.spine.client.Subscription> responseObserver) throws InvalidRequestException
topic
- defines the subscription targetresponseObserver
- the observer for obtaining created subscriptionInvalidRequestException
public void subscribe(io.spine.client.Subscription subscription) throws InvalidRequestException
Stand
.
The given subscription is shared between different Bounded Contexts.
subscription
- an existing subscriptionInvalidRequestException
public void activate(io.spine.client.Subscription subscription, SubscriptionCallback callback, io.grpc.stub.StreamObserver<io.spine.core.Response> responseObserver) throws InvalidRequestException
subscribe()
method.
After the activation, the clients will start receiving the updates via the passed
SubscriptionCallback
.
subscription
- the subscription to activatecallback
- the action which notifies the subscribers about an updateresponseObserver
- an observer to notify of a successful acknowledgement of the subscription activationInvalidRequestException
Stand.subscribe(Topic, StreamObserver)
public void cancel(io.spine.client.Subscription subscription, io.grpc.stub.StreamObserver<io.spine.core.Response> responseObserver) throws InvalidRequestException
Subscription
.
Typically invoked to cancel the previous
activate()
call.
After this method is called, the subscribers stop receiving the updates,
related to the given Subscription
.
subscription
- the subscription to cancelresponseObserver
- an observer to notify of a successful acknowledgement of the subscription
cancellation.InvalidRequestException
public Listener<EventEnvelope> eventListener()
public com.google.common.collect.ImmutableSet<io.spine.type.TypeUrl> exposedTypes()
Entity
types exposed for reading by this instance of Stand
.
In order to expose the type, use Stand.registerTypeSupplier(Repository)
.
The result includes all values from Stand.exposedAggregateTypes()
as well.
TypeUrl
instancespublic com.google.common.collect.ImmutableSet<io.spine.type.TypeUrl> exposedEventTypes()
Stand
.TypeUrl
instancespublic com.google.common.collect.ImmutableSet<io.spine.type.TypeUrl> exposedAggregateTypes()
Aggregate
entity types
exposed for reading by this instance of Stand
.
Use Stand.registerTypeSupplier(Repository)
to expose an Aggregate
type.
TypeUrl
instancespublic void execute(io.spine.client.Query query, io.grpc.stub.StreamObserver<io.spine.client.QueryResponse> responseObserver) throws InvalidRequestException
Query
defines the query target and the expected detail level for response.
The query results are fed to an instance
of StreamObserver
<QueryResponse
>.
query
- the instance of queryresponseObserver
- the observer to feed the query results toInvalidRequestException
public void registerTypeSupplier(Repository<?,?> repository)
Repository
as an entity/event type supplier.public void registerTypeSupplier(EventProducer producer)
EventProducer
as the event type supplier.public void close() throws java.lang.Exception
Stand
performing necessary cleanups.close
in interface java.lang.AutoCloseable
java.lang.Exception