Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haskell ledger bindings #1460

Merged
merged 8 commits into from
May 30, 2019
Merged

Haskell ledger bindings #1460

merged 8 commits into from
May 30, 2019

Conversation

nickchapman-da
Copy link
Contributor

Haskell ledger bindings, WIP

  • Attend to earlier code review comments
  • run tests in a shared sandbox; calling the reset-service between each test
  • expose gRPC cancel functionality in HighLevel interface (change to 3rd party code: gRPC-haskell)
  • cancel streaming RPCs when the attached Ledger Stream is closed, avoiding the 10s hang when using the sandbox reset-service -- Reset service takes ages to complete #1443

Copy link
Contributor

@neil-da neil-da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of getting a callback ClientCall -> IO () which is called once, should you instead be returning a pair of a stream and a ClientCall?

@@ -258,12 +258,14 @@ clientReader :: Client
-> TimeoutSeconds
-> ByteString -- ^ The body of the request
-> MetadataMap -- ^ Metadata to send with the request
-> (ClientCall -> IO ())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right API? Should you be returning the ClientCall?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you suggest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we make a new type which only allow cancel to be called.
But returning the LL.ClientCall is more general.
And the user only gets the ClientCall if they explicitly ask for it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning the pair of ClientCall and the value would have been my approach, if it fits. If the only sensible thing you can do is cancel it then return a pair of IO () (the cancel function) and the value. FWIW at a previous company I defined newtype Cancel = Cancel (IO ()) and it was quite a successful abstraction.

Copy link
Contributor Author

@nickchapman-da nickchapman-da May 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't return a pair because the interface is set up in a with-resource style, the ClientCall value being obtained from withClientCall.

I was about to introduce the Cancel abstraction you suggested, when I noticed that ClientCall and clientCallCancel were already exposed in the HighLevel interface. (The only thing missing was how to obtain a ClientCall value.)

Since the type of ClientCall is abstract, the only thing to be done is call clientCallCancel on it. And so it seems to fulfill the role of the suggested newtype.

So I the end, didn't add it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough on all points.

@nickchapman-da nickchapman-da merged commit 47e6d9a into master May 30, 2019
@dasormeter dasormeter deleted the haskell-ledger-bindings branch September 4, 2019 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/ledger Sandbox and Ledger API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants