Skip to content

WithResource combinator for Servant-managed resources#1630

Merged
tchoutri merged 2 commits intohaskell-servant:masterfrom
andremarianiello:servant-with-resource
Dec 29, 2022
Merged

WithResource combinator for Servant-managed resources#1630
tchoutri merged 2 commits intohaskell-servant:masterfrom
andremarianiello:servant-with-resource

Conversation

@andremarianiello
Copy link
Contributor

Hi! This is the PR discussed in #1345 , cookbook included.

@tchoutri
Copy link
Contributor

@andremarianiello Hi! Thank you for the PR. :) I see a couple of leftover TODOs, ping me when the PR is ready for review.

@andremarianiello
Copy link
Contributor Author

@tchoutri Whoops, sorry about that! I have replaced the TODO with documentation. Should be ready for review now.


hoistServerWithContext _ pc nt s = hoistServerWithContext (Proxy @api) pc nt . s

route Proxy context d = route (Proxy @api) context (d `addParameterCheck` allocateResource)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This addParameterCheck feels a bit hacky to me because allocateResource is not actually doing a parameter check, but I don't know of a better way to incorporate this allocation into the underlying ResourceT. If using addParameterCheck this way is too egregious I am of course open to alternatives.

@andremarianiello
Copy link
Contributor Author

@tchoutri ready for review

@andremarianiello
Copy link
Contributor Author

Do you have any idea what is causing the CI failures? I don't see how they are related to my changes and I cannot reproduce the failure locally.

@andremarianiello
Copy link
Contributor Author

Lots of successes in the last run, but the failure looks like its caused by

/home/runner/.stack/snapshots/x86_64-linux-tinfo6/56b3fcb84982f013f91c3bba340a6ce16510bb53707b2db3c5de7acb17a328cb/8.10.4/lib/x86_64-linux-ghc-8.10.4/HsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp/libHSHsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp.a(Session.o):function HsOpenSSLzm0zi11zi7zi1zm7zzNQfhMHQ8IBUiEb0198cp_OpenSSLziSession_zdwio_info: error: undefined reference to 'SSL_get_peer_certificate'
servant-http-streams> /home/runner/.stack/snapshots/x86_64-linux-tinfo6/56b3fcb84982f013f91c3bba340a6ce16510bb53707b2db3c5de7acb17a328cb/8.10.4/lib/x86_64-linux-ghc-8.10.4/HsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp/libHSHsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp.a(HsOpenSSL.o):function HsOpenSSL_EVP_MD_size: error: undefined reference to 'EVP_MD_size'
servant-http-streams> /home/runner/.stack/snapshots/x86_64-linux-tinfo6/56b3fcb84982f013f91c3bba340a6ce16510bb53707b2db3c5de7acb17a328cb/8.10.4/lib/x86_64-linux-ghc-8.10.4/HsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp/libHSHsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp.a(HsOpenSSL.o):function HsOpenSSL_EVP_CIPHER_CTX_block_size: error: undefined reference to 'EVP_CIPHER_CTX_block_size'
servant-http-streams> /home/runner/.stack/snapshots/x86_64-linux-tinfo6/56b3fcb84982f013f91c3bba340a6ce16510bb53707b2db3c5de7acb17a328cb/8.10.4/lib/x86_64-linux-ghc-8.10.4/HsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp/libHSHsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp.a(HsOpenSSL.o):function HsOpenSSL_EVP_CIPHER_iv_length: error: undefined reference to 'EVP_CIPHER_iv_length'
servant-http-streams> /home/runner/.stack/snapshots/x86_64-linux-tinfo6/56b3fcb84982f013f91c3bba340a6ce16510bb53707b2db3c5de7acb17a328cb/8.10.4/lib/x86_64-linux-ghc-8.10.4/HsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp/libHSHsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp.a(PKey.o):function HsOpenSSLzm0zi11zi7zi1zm7zzNQfhMHQ8IBUiEb0198cp_OpenSSLziEVPziPKey_zdwzdsrsaFromPKey1_info: error: undefined reference to 'EVP_PKEY_base_id'
servant-http-streams> /home/runner/.stack/snapshots/x86_64-linux-tinfo6/56b3fcb84982f013f91c3bba340a6ce16510bb53707b2db3c5de7acb17a328cb/8.10.4/lib/x86_64-linux-ghc-8.10.4/HsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp/libHSHsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp.a(PKey.o):function HsOpenSSLzm0zi11zi7zi1zm7zzNQfhMHQ8IBUiEb0198cp_OpenSSLziEVPziPKey_zdwzdsrsaFromPKey_info: error: undefined reference to 'EVP_PKEY_base_id'
servant-http-streams> /home/runner/.stack/snapshots/x86_64-linux-tinfo6/56b3fcb84982f013f91c3bba340a6ce16510bb53707b2db3c5de7acb17a328cb/8.10.4/lib/x86_64-linux-ghc-8.10.4/HsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp/libHSHsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp.a(PKey.o):function HsOpenSSLzm0zi11zi7zi1zm7zzNQfhMHQ8IBUiEb0198cp_OpenSSLziEVPziPKey_zdwzdsdsaFromPKey1_info: error: undefined reference to 'EVP_PKEY_base_id'
servant-http-streams> /home/runner/.stack/snapshots/x86_64-linux-tinfo6/56b3fcb84982f013f91c3bba340a6ce16510bb53707b2db3c5de7acb17a328cb/8.10.4/lib/x86_64-linux-ghc-8.10.4/HsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp/libHSHsOpenSSL-0.11.7.1-7zNQfhMHQ8IBUiEb0198cp.a(PKey.o):function HsOpenSSLzm0zi11zi7zi1zm7zzNQfhMHQ8IBUiEb0198cp_OpenSSLziEVPziPKey_zdwzdsdsaFromPKey_info: error: undefined reference to 'EVP_PKEY_base_id'
servant-http-streams> collect2: error: ld returned 1 exit status
servant-http-streams> `gcc' failed in phase `Linker'. (Exit code: 1)

Any idea what's going on?

@tchoutri
Copy link
Contributor

Yes, I'm going to disable the stack CI for the foreseeable future, it's no longer a good indicator of software quality.

@tchoutri tchoutri merged commit 751350b into haskell-servant:master Dec 29, 2022
tchoutri pushed a commit to tchoutri/servant that referenced this pull request Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants