Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-946

Add functionality to mongosh to decode a resume token

    XMLWordPrintable

Details

    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 1.0.6
    • None
    • None
    • 3
    • Needed
    • Hide
      We provide a snippet (see DOCSP-16500 for details on snippets, still open atm) for decoding resume tokens. Users can run `snippet install resumetoken` and then use the `decodeResumeToken()` method on a change stream resume token; for example:

      {code}
      > cs = db.test.watch()
      ChangeStreamCursor on test
      > token = cs.getResumeToken()
      { _data: '82612F69A2000000022B0229296E04' }
      // Either apply decodeResumeToken() to the token object...
      > decodeResumeToken(token)
      {
        timestamp: new Timestamp({ t: 1630497186, i: 2 }),
        version: 1,
        tokenType: 0,
        txnOpIndex: 0,
        fromInvalidate: false,
        uuid: undefined,
        documentKey: undefined
      }
      // ... or to the raw hex string
      > decodeResumeToken('82612F69A2000000022B0229296E04')
      {
        timestamp: new Timestamp({ t: 1630497186, i: 2 }),
        /* ... */
      }
      {code}

      I don’t know if it’s worth mentioning, but users who have npm installed (not necessarily mongosh) can also run `npx mongodb-resumetoken-decoder <hex string>` directly from the command line.
      Show
      We provide a snippet (see DOCSP-16500 for details on snippets, still open atm) for decoding resume tokens. Users can run `snippet install resumetoken` and then use the `decodeResumeToken()` method on a change stream resume token; for example: {code} > cs = db.test.watch() ChangeStreamCursor on test > token = cs.getResumeToken() { _data: '82612F69A2000000022B0229296E04' } // Either apply decodeResumeToken() to the token object... > decodeResumeToken(token) {   timestamp: new Timestamp({ t: 1630497186, i: 2 }),   version: 1,   tokenType: 0,   txnOpIndex: 0,   fromInvalidate: false,   uuid: undefined,   documentKey: undefined } // ... or to the raw hex string > decodeResumeToken('82612F69A2000000022B0229296E04') {   timestamp: new Timestamp({ t: 1630497186, i: 2 }),   /* ... */ } {code} I don’t know if it’s worth mentioning, but users who have npm installed (not necessarily mongosh) can also run `npx mongodb-resumetoken-decoder <hex string>` directly from the command line.
    • Iteration Johannesburg

    Description

      We had a request in SERVER-55978 to add something in the legacy shell to decode a resume token. It sounds like we are moving to prefer mongosh instead, so I've filed this ticket in its stead.

      Attachments

        Issue Links

          Activity

            People

              anna.henningsen@mongodb.com Anna Henningsen
              kyle.suarez@mongodb.com Kyle Suarez
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: