Struct daml_grpc::service::DamlCommandService
source · [−]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
sourceimpl<'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
futures::executor::block_on(async {
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> !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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcepub fn into_request(self) -> Request<T>
pub fn into_request(self) -> Request<T>
Wrap the input message T in a tonic::Request
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more