Kantoor.Feeds.Sync (Kantoor v1.0.0)

Replaces the events of a subscribed calendar with the objects of a fresh feed, as one transaction: a reader sees the old events or the new ones, never a mixture, and a failure leaves the old ones in place.

The replacement is a difference, so that CalDAV clients synchronise what changed and not everything: an object whose content is the same keeps its ETag and revision, a changed or new one is written, and one that is no longer in the feed is deleted with a tombstone (sync-collection reports it as removed). All of it happens under one lock on the collection and moves the collection's revision (the sync token and ctag) once; a fetch that changes nothing does not move it.

Nothing here runs scheduling: no invitation, update or cancellation is ever sent for an event of a feed.

Summary

Functions

Makes collection_id's events exactly objects (Kantoor.Feeds.Parser's %{name:, body:} maps). {:ok, %{count:, changed:}}: the number of events now held and how many were written or removed.

Functions

replace(collection_id, objects)

@spec replace(Ecto.UUID.t(), [map()]) ::
  {:ok, %{count: non_neg_integer(), changed: non_neg_integer()}}
  | {:error, term()}

Makes collection_id's events exactly objects (Kantoor.Feeds.Parser's %{name:, body:} maps). {:ok, %{count:, changed:}}: the number of events now held and how many were written or removed.