@@ -34,13 +34,24 @@ class CoordinationSessionConfig implements IConfig {
3434 /// This should be at least twice the [heartbeatInterval] .
3535 final Duration nodeTimeout;
3636
37+ /// Determines whether on becoming coordinator, the node should
38+ /// also consume the coordination stream - specifically, this is used for
39+ /// a coordinator to be able to consume UserMessages (UserCoordinationMessage)
40+ /// within the coordination session, this allows for a session coordinator
41+ /// to also act as a participant in the session, and have similar latency
42+ /// characteristics as other nodes.
43+ /// Default is true.
44+
45+ final bool consumeCoordinationStreamAsCoordinator;
46+
3747 CoordinationSessionConfig ({
3848 required this .name,
3949 this .maxNodes = 10 ,
4050 this .minNodes = 1 ,
4151 this .heartbeatInterval = const Duration (seconds: 5 ),
4252 this .discoveryInterval = const Duration (seconds: 10 ),
4353 this .nodeTimeout = const Duration (seconds: 15 ),
54+ this .consumeCoordinationStreamAsCoordinator = true ,
4455 }) {
4556 validate (throwOnError: true );
4657 }
@@ -100,14 +111,18 @@ class CoordinationSessionConfig implements IConfig {
100111 'heartbeatInterval' : heartbeatInterval.inMilliseconds,
101112 'discoveryInterval' : discoveryInterval.inMilliseconds,
102113 'nodeTimeout' : nodeTimeout.inMilliseconds,
114+ 'consumeCoordinationStreamAsCoordinator' :
115+ consumeCoordinationStreamAsCoordinator,
103116 };
104117 }
105118
106119 @override
107120 String toString () {
108121 return 'NetworkSessionConfig(name: $name , maxNodes: $maxNodes , '
109122 'minNodes: $minNodes , heartbeatInterval: $heartbeatInterval , '
110- 'discoveryInterval: $discoveryInterval , nodeTimeout: $nodeTimeout )' ;
123+ 'discoveryInterval: $discoveryInterval , nodeTimeout: $nodeTimeout , '
124+ 'consumeCoordinationStreamAsCoordinator: '
125+ '$consumeCoordinationStreamAsCoordinator )' ;
111126 }
112127
113128 @override
@@ -118,6 +133,7 @@ class CoordinationSessionConfig implements IConfig {
118133 Duration ? heartbeatInterval,
119134 Duration ? discoveryInterval,
120135 Duration ? nodeTimeout,
136+ bool ? consumeCoordinationStreamAsCoordinator,
121137 }) {
122138 return CoordinationSessionConfig (
123139 name: name ?? this .name,
@@ -126,6 +142,9 @@ class CoordinationSessionConfig implements IConfig {
126142 heartbeatInterval: heartbeatInterval ?? this .heartbeatInterval,
127143 discoveryInterval: discoveryInterval ?? this .discoveryInterval,
128144 nodeTimeout: nodeTimeout ?? this .nodeTimeout,
145+ consumeCoordinationStreamAsCoordinator:
146+ consumeCoordinationStreamAsCoordinator ??
147+ this .consumeCoordinationStreamAsCoordinator,
129148 );
130149 }
131150
@@ -137,6 +156,7 @@ class CoordinationSessionConfig implements IConfig {
137156 heartbeatInterval: const Duration (seconds: 5 ),
138157 discoveryInterval: const Duration (seconds: 10 ),
139158 nodeTimeout: const Duration (seconds: 15 ),
159+ consumeCoordinationStreamAsCoordinator: true ,
140160 );
141161 }
142162
@@ -151,7 +171,9 @@ class CoordinationSessionConfig implements IConfig {
151171 other.minNodes == minNodes &&
152172 other.heartbeatInterval == heartbeatInterval &&
153173 other.discoveryInterval == discoveryInterval &&
154- other.nodeTimeout == nodeTimeout;
174+ other.nodeTimeout == nodeTimeout &&
175+ other.consumeCoordinationStreamAsCoordinator ==
176+ consumeCoordinationStreamAsCoordinator;
155177 }
156178
157179 @override
@@ -162,7 +184,8 @@ class CoordinationSessionConfig implements IConfig {
162184 minNodes.hashCode ^
163185 heartbeatInterval.hashCode ^
164186 discoveryInterval.hashCode ^
165- nodeTimeout.hashCode;
187+ nodeTimeout.hashCode ^
188+ consumeCoordinationStreamAsCoordinator.hashCode;
166189 }
167190}
168191
0 commit comments