-
Notifications
You must be signed in to change notification settings - Fork 52
Switch to HTTP interface for Ogmios #1669
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
5c601fe
Use HTTP instead of WebSocket for Ogmios
marcusbfs 14a6d9d
Remove mempool methods from `QueryM.Ogmios`
marcusbfs 12896f5
Fix warning
marcusbfs 219f497
Use HTTP version of `evaluateTx`
marcusbfs 141a59b
Extract Ogmios types into separate module
marcusbfs 83b2c49
Clean and simplify Ogmios related code
marcusbfs 5f963f1
Move mempool related types to `Ogmios.Mempool`
marcusbfs 5c2d73f
Fix IPV6 parser
marcusbfs 2c0c04d
Move `DecodeOgmios` to `Ogmios.Types`
marcusbfs af6d6f5
Rename `Ogmios.Queries` to `Ogmios.QueryEnv`
marcusbfs fb55251
Remove `uniqueId` and `ServerConfig` dependencies from Ogmios.Mempool
marcusbfs ea54320
Extract common configuration out of `Ogmios.Mempool`
marcusbfs 2dcaa81
Remove unused exports
marcusbfs 2d2196f
Omit "id" field for Ogmios HTTP request/response
marcusbfs 2c8db1f
Simplify error handling
marcusbfs 796868f
Reuse `aesonObject`
marcusbfs 9a214a8
Simplify error handling
marcusbfs f8fea7c
Add `HttpUtils`
marcusbfs adba5b1
Clean duplicated code
marcusbfs febc66a
Remove websocket runtime from `QueryEnv`
marcusbfs 06a5955
Refactor mempool code structure
marcusbfs 99b98a0
Remove `resendPendingSubmitRequests` in websocket internals
marcusbfs 946c443
Remove internal CTL helper functions from mempool
marcusbfs 2718d8a
Remove unused code
marcusbfs 303e7f4
Refactor `OgmiosDecodeError`
marcusbfs ace529e
Improve HTTP handler readability
marcusbfs d8ba070
Update changelog
marcusbfs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| -- | This module defines utilities for working with HTTP requests | ||
| module Ctl.Internal.QueryM.HttpUtils | ||
| ( handleAffjaxResponseGeneric | ||
| ) where | ||
|
|
||
| import Prelude | ||
|
|
||
| import Aeson (JsonDecodeError) | ||
| import Affjax (Error, Response) as Affjax | ||
| import Affjax.StatusCode as Affjax.StatusCode | ||
| import Data.Bifunctor (lmap) | ||
| import Data.Either (Either(Left, Right)) | ||
|
|
||
| -------------------------------------------------------------------------------- | ||
| -- Affjax | ||
| -------------------------------------------------------------------------------- | ||
|
|
||
| -- Checks response status code and returns `ClientError` in case of failure, | ||
| -- otherwise attempts to decode the result. | ||
| -- | ||
| -- This function solves the problem described there: | ||
| -- https://github.com/eviefp/purescript-affjax-errors | ||
|
|
||
| handleAffjaxResponseGeneric | ||
| :: forall err intermediate result | ||
| . (Affjax.Error -> err) | ||
| -- ^ Convert an Affjax error into custom error | ||
| -> (Int -> String -> err) | ||
| -- ^ Convert a non-2xx status code into custom error | ||
| -> (String -> JsonDecodeError -> err) | ||
| -- ^ Wrap aeson-parse/decode errors | ||
| -> (String -> Either JsonDecodeError intermediate) | ||
| -- ^ Parse the response body | ||
| -> (intermediate -> Either err result) | ||
| -- ^ Function from `intermediate` to `result` | ||
| -> Either Affjax.Error (Affjax.Response String) | ||
| -- ^ Argument | ||
| -> Either err result | ||
| handleAffjaxResponseGeneric | ||
| mkHttpError | ||
| mkHttpResponseError | ||
| mkDecodeError | ||
| decodeAeson | ||
| mkResult = | ||
| case _ of | ||
| Left affjaxError -> | ||
| Left (mkHttpError affjaxError) | ||
| Right { status: Affjax.StatusCode.StatusCode statusCode, body } | ||
| | statusCode < 200 || statusCode > 299 -> | ||
| Left (mkHttpResponseError statusCode body) | ||
| | otherwise -> do | ||
| intermediate <- lmap (mkDecodeError body) do | ||
| decodeAeson body | ||
| mkResult intermediate | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function could accept a record for better readability. Also, it might not need to be so generic, especially if we can reuse the same error type.