Skip to content

refactor passing down of watch flags to avoid bugs #2861

@miparnisari

Description

@miparnisari

Originally posted by @miparnisari in #2859 (review)

We've seen two instances (one: #2636, the other caught in a PR #2859) where a server flag wasn't passed down properly to the datastore's implementation of the server method being called.

this is because the process of passing down a flag involves too many changes and it is VERY to miss a step.

i think a refactor is due.

proposal for Watch:

  • split datastore.WatchOptions struct to ServerWatchOptions and ClientWatchOptions
  • add a new datastore.WatchOptionsDefaults interface method that must be overriden per datastore
  • introduce a common fn merge(serverOptions, defaultDsOptions, clientWatchOptions) -> ClientAndServerOptions. also, serverWatchOptions are the same no matter the datastore, so they don't need to live in the cds or memdb implementations, they could live inside watchServer,
  • have server.Watch() call the merge function
  • then we change the datastore.Watch interface to take ClientAndServerOptions

This proposal could later be extended to other APIs.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions