Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-547

Causal Consistency Examples for the Manual

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Component/s: Docs Examples
    • None

      Hi –
      could we get the following causal consistency examples for the various drivers?
      I mocked up the template in python

      
         # Start Causal Consistency Example 1
      
          with client.start_session(causal_consistency=True) as s1:
              current_date = datetime.datetime.today()
              items = client.get_database('test', 
                                          read_concern=ReadConcern("majority"),
                                          write_concern=WriteConcern(w='majority', wtimeout=1000)).items
              items.update_one({'sku': "111", 'end': None }, {'$set': {'end': current_date}}, session=s1)
              items.insert_one({'sku': "nuts-111", 'name': "Pecans", 'start': current_date}, session=s1)
      
         # End Causal Consistency Example 1
      
         # Start Causal Consistency Example 2
      
          with client.start_session(causal_consistency=True) as s2:
              s2.advance_cluster_time(s1.cluster_time)
              s2.advance_operation_time(s1.operation_time)
      
              items = client.get_database('test', read_preference=ReadPreference.SECONDARY,
                                          read_concern=ReadConcern("majority"),
                                          write_concern=WriteConcern(w='majority', wtimeout=1000)).items
              for item in items.find({'end': None}, session=s2):
                  print(item)
      
         # End Causal Consistency Example 2
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: