Daml Java Bindings: Use of Flowable vs Single (ex: Get Users vs Get Packages)

I notice some differences in the return types of some of the clients in the Java bindings:

Example: using ledgerClient.packageClient.listPackages() returns a Flowable but running ledgerClient.userManagementClient.listUsers() returns a Single.

Is this by design? why is list of packages a publisher of flowable but users returning a single?

Thanks!

1 Like

At its core, the client libraries exposed by the Java bindings are a bit more high-level than the callback-based gRPC-generated code. Still, they are a relatively thin shim. This means that when the Ledger API returns a stream, an RxJAva Flowable is returned by the Java bindings and when a single result is returned instead an RxJava Single is returned. The user management API has been designed more recently (it’s part of the Ledger API only since 2.0) and followed slightly different design patterns (presented here) than the package management API, which results in this discrepancy.

@stefanobaghino-da is the bindings supposed to be updated with pagination support? ListUsers() does not seem to support passing the ListUsersRequest object:

Thanks for letting us know, I checked the implementation and this looks like a bug. Based on what I found you should be able to retrieve the first 1000 users as that is the default page size in the implementation, but without a token that’s the maximum extent to which you can go. I opened this ticket to keep track of the issue.

Great thanks