@@ -602,9 +602,9 @@ const (
602602 WatchCheckpoints WatchContent = 1 << 2
603603)
604604
605- // ServerWatchConfig contains server-level configuration for Watch operations.
605+ // ServerWatchOptions contains server-level configuration for Watch operations.
606606// These values do NOT change during the lifetime of a server.
607- type ServerWatchConfig struct {
607+ type ServerWatchOptions struct {
608608 // CheckpointInterval is the interval to use for checkpointing in the watch.
609609 CheckpointInterval time.Duration
610610
@@ -635,22 +635,21 @@ type ClientWatchOptions struct {
635635}
636636
637637// WatchOptions are ALL options for a Watch call.
638- // This struct combines server configuration, client requests, and datastore defaults
639- // into a single set of options passed to the datastore Watch implementation.
638+ // Some datastore implementations may ignore one or more of these.
640639type WatchOptions struct {
641640 // See ClientWatchOptions.Content
642641 Content WatchContent
643642 // See ClientWatchOptions.EmissionStrategy
644643 EmissionStrategy EmissionStrategy
645- // See ServerWatchConfig .CheckpointInterval
644+ // See ServerWatchOptions .CheckpointInterval
646645 CheckpointInterval time.Duration
647- // See ServerWatchConfig .WatchBufferLength
646+ // See ServerWatchOptions .WatchBufferLength
648647 WatchBufferLength uint16
649- // See ServerWatchConfig .WatchBufferWriteTimeout
648+ // See ServerWatchOptions .WatchBufferWriteTimeout
650649 WatchBufferWriteTimeout time.Duration
651- // See ServerWatchConfig .WatchConnectTimeout
650+ // See ServerWatchOptions .WatchConnectTimeout
652651 WatchConnectTimeout time.Duration
653- // See ServerWatchConfig .MaximumBufferedChangesByteSize
652+ // See ServerWatchOptions .MaximumBufferedChangesByteSize
654653 MaximumBufferedChangesByteSize uint64
655654}
656655
@@ -672,7 +671,7 @@ const (
672671// WatchJustRelationships returns watch options for just relationships.
673672func WatchJustRelationships (ds Datastore ) WatchOptions {
674673 v , _ := BuildAndValidateWatchOptions (
675- ServerWatchConfig {},
674+ ServerWatchOptions {},
676675 ClientWatchOptions {Content : WatchRelationships },
677676 ds .DefaultsWatchOptions (),
678677 )
@@ -682,7 +681,7 @@ func WatchJustRelationships(ds Datastore) WatchOptions {
682681// WatchJustSchema returns watch options for just schema.
683682func WatchJustSchema (ds ReadOnlyDatastore ) WatchOptions {
684683 v , _ := BuildAndValidateWatchOptions (
685- ServerWatchConfig {},
684+ ServerWatchOptions {},
686685 ClientWatchOptions {Content : WatchSchema },
687686 ds .DefaultsWatchOptions (),
688687 )
@@ -731,25 +730,27 @@ func watchBufferSize(sizeString string) (size uint64, err error) {
731730 return size , nil
732731}
733732
734- // BuildAndValidateWatchOptions constructs complete WatchOptions by merging server configuration,
735- // client requests, and datastore defaults.
733+ // BuildAndValidateWatchOptions constructs complete WatchOptions by merging server options,
734+ // client options, and datastore defaults.
735+ // Datastore defaults take precedence over server options.
736+ // Client options cannot be overridden.
736737func BuildAndValidateWatchOptions (
737- serverConfig ServerWatchConfig ,
738- clientRequest ClientWatchOptions ,
738+ serverOptions ServerWatchOptions ,
739+ clientOptions ClientWatchOptions ,
739740 datastoreDefaults WatchOptions ,
740741) (WatchOptions , error ) {
741- watchChangeBufferMaximumSize , err := watchBufferSize (serverConfig .MaximumBufferedChangesByteSize )
742+ watchChangeBufferMaximumSize , err := watchBufferSize (serverOptions .MaximumBufferedChangesByteSize )
742743 if err != nil {
743744 return WatchOptions {}, err
744745 }
745746
746747 options := WatchOptions {
747- Content : clientRequest .Content ,
748- EmissionStrategy : clientRequest .EmissionStrategy ,
749- CheckpointInterval : serverConfig .CheckpointInterval ,
750- WatchBufferLength : serverConfig .WatchBufferLength ,
751- WatchBufferWriteTimeout : serverConfig .WatchBufferWriteTimeout ,
752- WatchConnectTimeout : serverConfig .WatchConnectTimeout ,
748+ Content : clientOptions .Content ,
749+ EmissionStrategy : clientOptions .EmissionStrategy ,
750+ CheckpointInterval : serverOptions .CheckpointInterval ,
751+ WatchBufferLength : serverOptions .WatchBufferLength ,
752+ WatchBufferWriteTimeout : serverOptions .WatchBufferWriteTimeout ,
753+ WatchConnectTimeout : serverOptions .WatchConnectTimeout ,
753754 MaximumBufferedChangesByteSize : watchChangeBufferMaximumSize ,
754755 }
755756
@@ -825,7 +826,7 @@ type ReadOnlyDatastore interface {
825826 Watch (ctx context.Context , afterRevision Revision , options WatchOptions ) (<- chan RevisionChanges , <- chan error )
826827
827828 // DefaultsWatchOptions returns the default watch options for this datastore.
828- // These defaults are used when building WatchOptions from ServerWatchConfig and ClientWatchOptions.
829+ // These defaults are used when building WatchOptions from ServerWatchOptions and ClientWatchOptions.
829830 // Each datastore should return appropriate defaults based on its capabilities and constraints.
830831 DefaultsWatchOptions () WatchOptions
831832
0 commit comments