pub struct DamlCommandService<'a> { /* private fields */ }
Expand description
Submit commands to a Daml ledger and await the completion.
The Command Service is able to correlate submitted commands with completion data, identify timeouts, and return contextual information with each tracking result. This supports the implementation of stateless clients.
Implementations§
Source§impl<'a> DamlCommandService<'a>
impl<'a> DamlCommandService<'a>
Sourcepub fn new(
channel: Channel,
ledger_id: &'a str,
auth_token: Option<&'a str>,
) -> Self
pub fn new( channel: Channel, ledger_id: &'a str, auth_token: Option<&'a str>, ) -> Self
Create a DamlCommandService
for a given GRPC channel
and ledger_id
.
Sourcepub fn with_token(self, auth_token: &'a str) -> Self
pub fn with_token(self, auth_token: &'a str) -> Self
Override the JWT token to use for this service.
Sourcepub fn with_ledger_id(self, ledger_id: &'a str) -> Self
pub fn with_ledger_id(self, ledger_id: &'a str) -> Self
Override the ledger id to use for this service.
Sourcepub async fn submit_and_wait(
&self,
commands: impl Into<DamlCommands> + Debug,
) -> DamlResult<String>
pub async fn submit_and_wait( &self, commands: impl Into<DamlCommands> + Debug, ) -> DamlResult<String>
Submits a composite DamlCommands
and await the completion.
This method executes commands
synchronously on the ledger server (unlike the
DamlCommandSubmissionService
which is executed asynchronously on the ledger server). This service only
waits for the completion of the execution of the command, not the propagation of any resulting events which
must be consumed via the DamlTransactionService
.
Note that this method is executed asynchronously on the client side and so will immediately return a future which must be driven to completion before a result can be observed.
§Errors
Propagates communication failure errors as GrpcTransportError
and Daml server failures as
GRPCStatusError
errors.
§Examples
let ledger_client = DamlGrpcClientBuilder::uri("http://127.0.0.1").connect().await?;
let future_command = ledger_client.command_service().submit_and_wait(commands).await;
match future_command {
Ok(command_id) => assert_eq!("1234", command_id),
Err(e) => panic!("submit_and_wait failed, error was {}", e.to_string()),
}
Sourcepub async fn submit_and_wait_for_transaction_id(
&self,
commands: impl Into<DamlCommands> + Debug,
) -> DamlResult<(String, String)>
pub async fn submit_and_wait_for_transaction_id( &self, commands: impl Into<DamlCommands> + Debug, ) -> DamlResult<(String, String)>
Submits a composite DamlCommands
and returns the resulting transaction id.
DOCME fully document this
TODO ugly API returning a tuple as completion_offset
was recently added, refactor
Sourcepub async fn submit_and_wait_for_transaction(
&self,
commands: impl Into<DamlCommands> + Debug,
) -> DamlResult<(DamlTransaction, String)>
pub async fn submit_and_wait_for_transaction( &self, commands: impl Into<DamlCommands> + Debug, ) -> DamlResult<(DamlTransaction, String)>
Submits a composite DamlCommands
and returns the resulting DamlTransaction
.
DOCME fully document this
TODO ugly API returning a tuple as completion_offset
was recently added, refactor
Sourcepub async fn submit_and_wait_for_transaction_tree(
&self,
commands: impl Into<DamlCommands> + Debug,
) -> DamlResult<(DamlTransactionTree, String)>
pub async fn submit_and_wait_for_transaction_tree( &self, commands: impl Into<DamlCommands> + Debug, ) -> DamlResult<(DamlTransactionTree, String)>
Submits a composite DamlCommands
and returns the resulting DamlTransactionTree
.
DOCME fully document this
TODO ugly API returning a tuple as completion_offset
was recently added, refactor
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for DamlCommandService<'a>
impl<'a> !RefUnwindSafe for DamlCommandService<'a>
impl<'a> Send for DamlCommandService<'a>
impl<'a> Sync for DamlCommandService<'a>
impl<'a> Unpin for DamlCommandService<'a>
impl<'a> !UnwindSafe for DamlCommandService<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request