public interface Context
Context
contains information about the current function invocation, such as the invoked
function instance's and caller's Address
. It is also used for side-effects as a result of
the invocation such as send messages to other functions or egresses, and provides access to
AddressScopedStorage
scoped to the current Address
.Modifier and Type | Method and Description |
---|---|
java.util.Optional<Address> |
caller() |
void |
cancelDelayedMessage(java.lang.String cancellationToken)
Cancel a delayed message (a message that was send via
sendAfter(Duration, Message) ). |
default java.util.concurrent.CompletableFuture<java.lang.Void> |
done() |
Address |
self() |
void |
send(EgressMessage message)
Sends out a
EgressMessage to an egress. |
void |
send(Message message)
Sends out a
Message to another function. |
void |
sendAfter(java.time.Duration duration,
Message message)
Sends out a
Message to another function, after a specified Duration delay. |
void |
sendAfter(java.time.Duration duration,
java.lang.String cancellationToken,
Message message)
Sends out a
Message to another function, after a specified Duration delay. |
AddressScopedStorage |
storage() |
java.util.Optional<Address> caller()
Address
, if applicable. This is Optional.empty()
if the message was sent to this function via an ingress.void send(Message message)
Message
to another function.message
- the message to send.void sendAfter(java.time.Duration duration, Message message)
Message
to another function, after a specified Duration
delay.duration
- the amount of time to delay the message delivery.message
- the message to send.void sendAfter(java.time.Duration duration, java.lang.String cancellationToken, Message message)
Message
to another function, after a specified Duration
delay.duration
- the amount of time to delay the message delivery. * @param cancellationTokencancellationToken
- the non-empty, non-null, unique token to attach to this message, to be
used for message cancellation. (see cancelDelayedMessage(String)
.)message
- the message to send.void cancelDelayedMessage(java.lang.String cancellationToken)
sendAfter(Duration, Message)
).
NOTE: this is a best-effort operation, since the message might have been already delivered. If the message was delivered, this is a no-op operation.
cancellationToken
- the id of the message to un-send.void send(EgressMessage message)
EgressMessage
to an egress.message
- the message to send.AddressScopedStorage storage()
AddressScopedStorage
, providing access to stored values scoped to the
current invoked function instance's Address
(which is obtainable using self()
).default java.util.concurrent.CompletableFuture<java.lang.Void> done()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.