How to disconnect MongoDB in Julia - Stack Overflow

Quick and simple question.I have starting to use Mongoc.jl to implement MongoDB procedure into my Jete

Quick and simple question. I have starting to use Mongoc.jl to implement MongoDB procedure into my Jetelina project. I found "how to connect" in its manual, but nothing "how to disconnect". I wonder MongoDB should not cut the connection in each?

Quick and simple question. I have starting to use Mongoc.jl to implement MongoDB procedure into my Jetelina project. I found "how to connect" in its manual, but nothing "how to disconnect". I wonder MongoDB should not cut the connection in each?

Share Improve this question asked Nov 20, 2024 at 2:16 onokeonoke 1199 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

No worries, the package does all that housekeeping for you.

The following code is from https://github/felipenoris/Mongoc.jl/blob/100b732c53d6ce50417dc93c86218c7f92629ed0/src/types.jl:

function Client(uri::URI)
    client_handle = mongoc_client_new_from_uri(uri.handle)
    @assert client_handle != C_NULL "Failed to create client handle from URI $(uri.uri)."
    client = Client(uri.uri, client_handle, nothing)
    finalizer(destroy!, client)
    return client
end

The Mongoc.jl package's Client struct represents a database connection. The finalizer (see https://docs.julialang./en/v1/base/base/#Base.finalizer) makes sure that when the client goes out of scope (or at the end of your program, if client is a global) the handle is closed.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742386327a4434132.html

相关推荐

  • How to disconnect MongoDB in Julia - Stack Overflow

    Quick and simple question.I have starting to use Mongoc.jl to implement MongoDB procedure into my Jete

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信