public final class DamlLedgerClient extends java.lang.Object implements LedgerClient
LedgerClient
implementation that connects to
an existing Ledger and provides clients to query it. To use the DamlLedgerClient
:
DamlLedgerClient
using forLedgerIdAndHost(String, String, int, Optional)
,
forHostWithLedgerIdDiscovery(String, int, Optional)
or DamlLedgerClient(Optional, ManagedChannel)
connect()
to initialize the clients
for that particular LedgergetActiveContractSetClient()
SslContext
object for mutual authentication please refer to
the section on security in the grpc-java documentation.Constructor and Description |
---|
DamlLedgerClient(java.util.Optional<java.lang.String> expectedLedgerId,
@NonNull io.grpc.ManagedChannel channel)
Creates a
DamlLedgerClient with a previously created ManagedChannel . |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
connect()
Connects this instance of the
DamlLedgerClient to the Ledger. |
static DamlLedgerClient |
forHostWithLedgerIdDiscovery(@NonNull java.lang.String hostIp,
int hostPort,
java.util.Optional<io.netty.handler.ssl.SslContext> sslContext)
Like
forLedgerIdAndHost(String, String, int, Optional) but with the ledger-id
automatically discovered instead of provided. |
static DamlLedgerClient |
forLedgerIdAndHost(@NonNull java.lang.String ledgerId,
@NonNull java.lang.String hostIp,
int hostPort,
@NonNull java.util.Optional<io.netty.handler.ssl.SslContext> sslContext)
Creates a
DamlLedgerClient connected to a Ledger
identified by the ip and port. |
ActiveContractsClient |
getActiveContractSetClient() |
CommandClient |
getCommandClient() |
CommandCompletionClient |
getCommandCompletionClient() |
CommandSubmissionClient |
getCommandSubmissionClient() |
LedgerConfigurationClient |
getLedgerConfigurationClient() |
java.lang.String |
getLedgerId() |
LedgerIdentityClient |
getLedgerIdentityClient() |
PackageClient |
getPackageClient() |
TimeClient |
getTimeClient() |
TransactionsClient |
getTransactionsClient() |
static void |
main(java.lang.String[] args) |
public DamlLedgerClient(java.util.Optional<java.lang.String> expectedLedgerId, @NonNull io.grpc.ManagedChannel channel)
DamlLedgerClient
with a previously created ManagedChannel
. This is useful in
case additional settings need to be configured for the connection to the ledger (e.g. keep alive timeout).expectedLedgerId
- If the value is present, connect()
throws an exception
if the provided ledger id does not match the ledger id provided by the ledger.channel
- A user provided instance of @ManagedChannel
.public static DamlLedgerClient forLedgerIdAndHost(@NonNull java.lang.String ledgerId, @NonNull java.lang.String hostIp, int hostPort, @NonNull java.util.Optional<io.netty.handler.ssl.SslContext> sslContext)
DamlLedgerClient
connected to a Ledger
identified by the ip and port.ledgerId
- The expected ledger-idhostIp
- The ip of the LedgerhostPort
- The port of the LedgersslContext
- If present, it will be used to establish a TLS connection. If empty, an unsecured plaintext connection will be used.
Must be an SslContext created for client applications via GrpcSslContexts.forClient()
.public static DamlLedgerClient forHostWithLedgerIdDiscovery(@NonNull java.lang.String hostIp, int hostPort, java.util.Optional<io.netty.handler.ssl.SslContext> sslContext)
forLedgerIdAndHost(String, String, int, Optional)
but with the ledger-id
automatically discovered instead of provided.public void connect()
DamlLedgerClient
to the Ledger.public java.lang.String getLedgerId()
getLedgerId
in interface LedgerClient
LedgerClient
public ActiveContractsClient getActiveContractSetClient()
getActiveContractSetClient
in interface LedgerClient
public TransactionsClient getTransactionsClient()
getTransactionsClient
in interface LedgerClient
public CommandClient getCommandClient()
getCommandClient
in interface LedgerClient
public CommandCompletionClient getCommandCompletionClient()
getCommandCompletionClient
in interface LedgerClient
public CommandSubmissionClient getCommandSubmissionClient()
getCommandSubmissionClient
in interface LedgerClient
public LedgerIdentityClient getLedgerIdentityClient()
getLedgerIdentityClient
in interface LedgerClient
public PackageClient getPackageClient()
getPackageClient
in interface LedgerClient
public LedgerConfigurationClient getLedgerConfigurationClient()
getLedgerConfigurationClient
in interface LedgerClient
public TimeClient getTimeClient()
getTimeClient
in interface LedgerClient
public void close() throws java.lang.Exception
java.lang.Exception
public static void main(java.lang.String[] args)