From 6ad28bc0a6bd29cd12fc20686556830c8b1abd0f Mon Sep 17 00:00:00 2001 From: why-not-try-calmer Date: Thu, 6 Jan 2022 23:43:29 +0100 Subject: [PATCH 1/2] Added a clarificatory remark and one example to openReplicaSet' Some new users might be put off by the lack of a array of choice between connection methods that this package offers. This remark and the associated examples are a first attempt to make the package easier to start with. -- --- Database/MongoDB/Connection.hs | 8 +++ Database/MongoDB/Internal/Protocol.hs | 3 +- dist-newstyle/cache/config | Bin 0 -> 11362 bytes stack.yaml | 69 ++++++++++++++++++++++++++ stack.yaml.lock | 13 +++++ 5 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 dist-newstyle/cache/config create mode 100644 stack.yaml create mode 100644 stack.yaml.lock diff --git a/Database/MongoDB/Connection.hs b/Database/MongoDB/Connection.hs index f6bfb6b..4b88cd6 100644 --- a/Database/MongoDB/Connection.hs +++ b/Database/MongoDB/Connection.hs @@ -172,6 +172,14 @@ openReplicaSetSRV hostname = do openReplicaSetSRV' :: HostName -> IO ReplicaSet -- ^ Open /secure/ connections (on demand) to servers in a replica set. The seedlist and replica set name is fetched from the SRV and TXT DNS records for the given hostname. The value of 'globalConnectTimeout' at the time of this call is the timeout used for future member connect attempts. To use your own value call 'openReplicaSetSRV'''' instead. +-- +-- The preferred connection method for cloud MongoDB providers. A typical connecting sequence is shown in the example below. +-- +-- ==== __Example__ +-- > do +-- > pipe <- openReplicatSetSRV' "cluster#.xxxxx.yyyyy.zzz" +-- > is_auth <- access pipe master "admin" $ auth user_name password +-- > unless (not is_auth) (throwIO $ userError "Authentication failed!") openReplicaSetSRV' hostname = do timeoutSecs <- readIORef globalConnectTimeout _openReplicaSetSRV timeoutSecs Secure hostname diff --git a/Database/MongoDB/Internal/Protocol.hs b/Database/MongoDB/Internal/Protocol.hs index 0f786f9..e87acd4 100644 --- a/Database/MongoDB/Internal/Protocol.hs +++ b/Database/MongoDB/Internal/Protocol.hs @@ -195,7 +195,8 @@ pcall p@Pipeline{..} message = do -- * Pipe type Pipe = Pipeline --- ^ Thread-safe TCP connection with pipelined requests +-- ^ Thread-safe TCP connection with pipelined requests. In long-running applications the user is expected to use it as a "client": create a `Pipe` +-- at startup, use it as long as possible, and close it on shutdown. Bearing in mind that disconnections may be triggered by MongoDB service providers, the user is responsible for re-creating their `Pipe` whenever necessary. newPipe :: ServerData -> Handle -> IO Pipe -- ^ Create pipe over handle diff --git a/dist-newstyle/cache/config b/dist-newstyle/cache/config new file mode 100644 index 0000000000000000000000000000000000000000..7e394911ca050e0b77cd8ca593a4a79749ac8c06 GIT binary patch literal 11362 zcmeHN&668P6_-}4U9Z+3B%zXuQ^3TBl%2BXOVUV6rBcp%9mkM$lJXjkR8M!0Gki@-Yf6t`EC(%avAC>R^ zO8n-&|6zRbUqAi%)e0gltDg+G)hCQ+@SQ#2Q8eadzLoQu!!-F3r^1X9N}{Ufv`^0& zq?~`sC#=^_%{npZ)gsT>DvKs@5ca^h+IRl+>wkXnv%egC{?(Pw_LLLKs+2_;D`gX@ zjS^B@V{uZ&`6-=h|b4N!>Fdu2w$9n*SqYyyroSE8vi9oURz>Gc!5 z93{QX@<(CBAOw0jRO1VtExmRE?~u?3q{lNH_mvYcQofX zv4mRXOIR=0%NGmu1*CVaFlPLr*%yOIwc)TY^~buJY89AC+Eb8fUx?vb2t-*+7!Xpn zkit@HkE-7Yc%$L8Y}d2Bj_n4VP^ZOPPLp;0E+?HvzulO7abdldex1E^WCUb13aP#0Nn>Yj{mgTfECV)c4vB@Hg8|r|kwFcfG(SyxnfF zri*f1>d}VhwteQ&ZpZC*ZMV^FcG>~RW46of4uNlv29C#>@7OKUu^pE+n@!ef+q8jl zY|^4_4r5W~_)aUZouC!89MWhI#z>oct(H&i!1is=Y59b7xZ8GuCIuTE?m7(Rv>agd z9KUOOw&VCM(9Z)$v_0P;ybER9X2k0@T-R|L#BF-S?gkyZO+B!%>pDtKMNeNL(o|o* z6JYJwYTkX50Ql)gRv{Bl?H8$5# z-T|8`Q--0D+aKJydF$@ITWYW?HviH3cmDp((m6e+6=vB;Z__gRwO1c+{Js4&{Di0Av?%1UxMl?4nuGD3 zCTGY#QfGmZC>v=+u-+<=HMi4Ec>BcU}4MaH85?1a&d zj*iScK$$O(77UwnI4n*c1|rrUp)8|NlyUy%`|sYped~h{Z<_<$Q0L@n@DG!S)nhJ> zlJtQ>-Mg8@B26OWsL#P&sdV=U-1l~VBEscy{>-%0R9Q+=-Ord&px-I%t=nptZ=e&< z_p1Hn*>>|?HVARKyf)Vh+RC7SiBJMwnSc}kcTwJG>Ru~?Cse=K+=(lG8V0m0@gNEpLryBM?$AT|n@jCDaF>Y!0d z7E7uOLyLsU;){VhDbJEo zO8GL&;UFNaF5L*5Yc6XOE-d)bleHU#f#9qzqa#Pjq&1&lfNIqCaFp_c{nlcgDw$Yf z+Lj=_9%oC~MI04wm@iMF!_;o$-K-B2lLi$(97oc?g6!lgH`O*m|J| zn|P;sk`HS#GT>y7_}GSx!o^Qp^MdrSeK?%xdHR=C9REMDTQnmmN-;&_-_re)?)G+l!xBX2I1);p1M1Qgmy>z!!56OF?{ zhs1g(k`B@Cs66>jG}#`{pO9&c-Cz8Ees9Y~Ex#5tPV=_P)8MLADb)(5AwV}_!znlr zs(CfBo?-2Zr%k{eBmdxhLA`jHE3EY0Lar_|3i*}>pVcAp42BrnF#nAq2FXo^xw%A5 ze&dm~?E}bJ%zlPw+4ekqP@kgqnCxuc8*-|Y+{qs&3JtYGF!#=&@F1bhnMjhPplf-uy|`PYn;M>T z>sqy+!HneVqNup;ugOQW{HM|-InjzFd__iu8E7m7WGV^SFHp9lb9}l5x3o`ej4H|of&uEYIs#n|O+$E_haWqZoMlU2?r@Q;mo0iimU_Eb zFI(-3tuuQbUoYDyUbZV9Qs(Xvg^(`B`I=2.7" +# +# Override the architecture used by stack, especially useful on Windows +# arch: i386 +# arch: x86_64 +# +# Extra directories used by stack for building +# extra-include-dirs: [/path/to/dir] +# extra-lib-dirs: [/path/to/dir] +# +# Allow a newer minor version of GHC than the snapshot specifies +# compiler-check: newer-minor diff --git a/stack.yaml.lock b/stack.yaml.lock new file mode 100644 index 0000000..efdd0c4 --- /dev/null +++ b/stack.yaml.lock @@ -0,0 +1,13 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: [] +snapshots: +- completed: + size: 586110 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/21.yaml + sha256: ce4fb8d44f3c6c6032060a02e0ebb1bd29937c9a70101c1517b92a87d9515160 + original: + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/21.yaml From 410fdd587ab49de9c42bdab8eacf5818a3aee866 Mon Sep 17 00:00:00 2001 From: why-not-try-calmer Date: Thu, 3 Feb 2022 08:46:16 +0100 Subject: [PATCH 2/2] Added "timeouts" as one type of events users should handle as part of their use of Pipeline. --- Database/MongoDB/Internal/Protocol.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Database/MongoDB/Internal/Protocol.hs b/Database/MongoDB/Internal/Protocol.hs index e87acd4..a86f4a1 100644 --- a/Database/MongoDB/Internal/Protocol.hs +++ b/Database/MongoDB/Internal/Protocol.hs @@ -196,7 +196,7 @@ pcall p@Pipeline{..} message = do type Pipe = Pipeline -- ^ Thread-safe TCP connection with pipelined requests. In long-running applications the user is expected to use it as a "client": create a `Pipe` --- at startup, use it as long as possible, and close it on shutdown. Bearing in mind that disconnections may be triggered by MongoDB service providers, the user is responsible for re-creating their `Pipe` whenever necessary. +-- at startup, use it as long as possible, watch out for possible timeouts, and close it on shutdown. Bearing in mind that disconnections may be triggered by MongoDB service providers, the user is responsible for re-creating their `Pipe` whenever necessary. newPipe :: ServerData -> Handle -> IO Pipe -- ^ Create pipe over handle