Skip to content

Commit

Permalink
Deploying to gh-pages from @ 19b14e4 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
inv2004 committed Sep 13, 2023
1 parent 9912c07 commit 7420f8a
Show file tree
Hide file tree
Showing 60 changed files with 1,677 additions and 1,679 deletions.
2 changes: 1 addition & 1 deletion anonimongo.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.6.5"
version = "0.6.6"
author = "Rahmatullah"
description = "Anonimongo - Another pure Nim Mongo driver"
license = "MIT"
Expand Down
27 changes: 12 additions & 15 deletions src/anonimongo/core/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -449,40 +449,37 @@ proc query*(m: Mongo): lent TableRef[string, seq[string]] =
m.query
proc flags*(m: Mongo): QueryFlags = m.flags

proc pickAnyServer[T: MultiSock](m: Mongo[T], test: (string, int) -> bool = nil): MongoConn[T] =
var res: MongoConn[T]
for host{.inject.}, server{.inject.} in m.servers:
#if `test`:
if test == nil or (test != nil and test(host, server.pool.available.len)):
res = server
res
template pickAnyServer(m: Mongo, test: untyped): untyped =
for hostname{.inject.}, theserver{.inject.} in m.servers:
if test:
result = theserver
break

proc main*[T: MultiSock](m: Mongo[T]): MongoConn[T] =
if m.primary == "":
#result = m.pickAnyServer true
result = m.pickAnyServer
m.pickAnyServer true
else:
result = m.servers[m.primary]

proc mainPreferred*[T: MultiSock](m: Mongo[T]): MongoConn[T] =
if m.primary == "":
result = m.pickAnyServer
m.pickAnyServer true
elif m.servers[m.primary].pool.available.len > 0:
result = m.servers[m.primary]
else:
result = m.pickAnyServer((host: string, num: int) => host != m.primary)
m.pickAnyServer: hostname != m.primary

proc secondary*[T: MultiSock](m: Mongo[T]): MongoConn[T] =
if m.primary == "":
result = m.pickAnyServer
m.pickAnyServer true
else:
result = m.pickAnyServer((host: string, num: int) => host != m.primary)
m.pickAnyServer: hostname != m.primary and theserver.pool.available.len > 0

proc secondaryPreferred*[T: MultiSock](m: Mongo[T]): MongoConn[T] =
if m.primary == "":
result = m.pickAnyServer
m.pickAnyServer true
else:
result = m.pickAnyServer((host: string, num: int) => host != m.primary and num > 0)
m.pickAnyServer: hostname != m.primary
if result == nil:
result = m.servers[m.primary]

Expand Down
4 changes: 2 additions & 2 deletions src/anonimongo/dbops/client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const
drivername = "anonimongo"
description = "nim mongo driver"
when not defined(anostreamable):
const anonimongoVersion* = "0.6.5"
const anonimongoVersion* = "0.6.6"
else:
const anonimongoVersion* = "0.6.5-stream"
const anonimongoVersion* = "0.6.6-stream"

proc handshake(m: Mongo[AsyncSocket], isMaster: bool, s: AsyncSocket, db: string, id: int32,
appname = "Anonimongo client apps"):Future[ReplyFormat] {.multisock.} =
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 7420f8a

Please sign in to comment.