Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1262

Support block form for using a session

    • 2
    • Fully Compatible

      client.with_session do |session|
        ....
      end
      

      So that the session can be closed after the block completes.

      We already have the with_session method but it appears to be private. I suggest changing start_session to optionally take a block.

      Requirements:

      Make start_session take a block, or verify this already happens.
      Add tests if needed for start_session with block.
      Add tests if needed for start_session with block where the block raises an exception, asserting the exception is propagated and the session is closed.
      Add a usage example to https://docs.mongodb.com/ruby-driver/master/tutorials/ruby-driver-sessions/. I suggest taking the first example in the section dealing with start_session, transforming it to use the block form, and making that the first example; then retaining the existing non-block form example as alternate way of using sessions.

            Assignee:
            neil.shweky@mongodb.com Neil Shweky (Inactive)
            Reporter:
            emily.stolfo Emily Stolfo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: