123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- (defvar *alice* (create-schema))
- (defvar *bob* (create-schema))
- (add-contact *alice* "bob" (getf *bob* :id))
- (add-contact *bob* "alice" (getf *alice* :id))
- (put-msg *alice* (list 0 (getf *alice* :id)) "food" "pizza")
- (put-msg *alice* (list 0 (getf *alice* :id)) "food" "tofu")
- ;;;; ONE WAY SYNC
- (process-eager-update *bob* (getf *alice* :id)
- (send-eager-update *alice* (getf *bob* :id)))
- *alice*
- *bob*
- ;;;; Create a merge conflict
- (put-msg *bob* (list 0 (getf *alice* :id)) "food" "salad")
- (put-msg *alice* (list 0 (getf *alice* :id)) "food" "pasta")
- ;;;; TWO WAY SYNC
- ;;;; note that order does not matter
- (process-eager-update *alice*
- (getf *bob* :id)
- (send-eager-update *bob* (getf *alice* :id)))
- (process-eager-update *bob*
- (getf *alice* :id)
- (send-eager-update *alice* (getf *bob* :id)))
- *alice*
- *bob*
- ;;;; Should be in sync now
- (get-msg *alice* (list 0 (getf *alice* :id)) "food")
- (get-msg *bob* (list 0 (getf *alice* :id)) "food")
- ;;;; Put objects into slots
- (let ((table (put-obj *bob* (list 0 (getf *alice* :id)) "contact")))
- (put-msg *bob* table "email" "someemail@email.com"))
- (let ((table (get-msg *bob* (list 0 (getf *alice* :id)) "contact")))
- (get-msg *bob* table "email")) ; "someemail@email.com
- *alice*
- *bob*
- (process-eager-update *alice*
- (getf *bob* :id)
- (send-eager-update *bob* (getf *alice* :id)))
- *alice*
- *bob*
- (let ((table (get-msg *alice* (list 0 (getf *alice* :id)) "contact")))
- (get-msg *alice* table "email")) ; "someemail@email.com
- (let ((table (get-msg *alice* (list 0 (getf *alice* :id)) "contact")))
- (put-msg *alice* table "email" "alice@email.com"))
- (process-eager-update *bob*
- (getf *alice* :id)
- (send-eager-update *alice* (getf *bob* :id)))
- (let ((table (get-msg *bob* (list 0 (getf *alice* :id)) "contact")))
- (get-msg *alice* table "email")) ; "alice@email.com
|