@@ -20,14 +20,21 @@ import {
2020export type RoutingInfo = AutoShardingRoutingInfo | StaticShardingRoutingInfo ;
2121
2222export abstract class BaseRoutingInfo {
23+ public pubsubTopic : PubsubTopic ;
24+ public shardId : ShardId ;
25+
2326 protected constructor (
2427 public networkConfig : NetworkConfig ,
25- public pubsubTopic : PubsubTopic ,
26- public shardId : ShardId
27- ) { }
28+ pubsubTopic : PubsubTopic ,
29+ shardId : ShardId
30+ ) {
31+ this . pubsubTopic = pubsubTopic ;
32+ this . shardId = shardId ;
33+ }
2834
29- public abstract get isAutoSharding ( ) : boolean ;
30- public abstract get isStaticSharding ( ) : boolean ;
35+ public get clusterId ( ) : ClusterId {
36+ return this . networkConfig . clusterId ;
37+ }
3138}
3239
3340export class AutoShardingRoutingInfo
@@ -61,24 +68,12 @@ export class AutoShardingRoutingInfo
6168 */
6269 private constructor (
6370 public networkConfig : AutoSharding ,
64- public pubsubTopic : PubsubTopic ,
65- public shardId : ShardId ,
71+ pubsubTopic : PubsubTopic ,
72+ shardId : ShardId ,
6673 public contentTopic : string
6774 ) {
6875 super ( networkConfig , pubsubTopic , shardId ) ;
6976 }
70-
71- public get clusterId ( ) : number {
72- return this . networkConfig . clusterId ;
73- }
74-
75- public get isAutoSharding ( ) : boolean {
76- return true ;
77- }
78-
79- public get isStaticSharding ( ) : boolean {
80- return false ;
81- }
8277}
8378
8479export class StaticShardingRoutingInfo
@@ -127,35 +122,23 @@ export class StaticShardingRoutingInfo
127122 */
128123 private constructor (
129124 public networkConfig : StaticSharding ,
130- public pubsubTopic : PubsubTopic ,
131- public shardId : ShardId
125+ pubsubTopic : PubsubTopic ,
126+ shardId : ShardId
132127 ) {
133128 super ( networkConfig , pubsubTopic , shardId ) ;
134129 }
135-
136- public get clusterId ( ) : ClusterId {
137- return this . networkConfig . clusterId ;
138- }
139-
140- public get isAutoSharding ( ) : boolean {
141- return false ;
142- }
143-
144- public get isStaticSharding ( ) : boolean {
145- return true ;
146- }
147130}
148131
149132export function isAutoShardingRoutingInfo (
150133 routingInfo : BaseRoutingInfo
151134) : routingInfo is AutoShardingRoutingInfo {
152- return routingInfo . isAutoSharding ;
135+ return routingInfo instanceof AutoShardingRoutingInfo ;
153136}
154137
155138export function isStaticShardingRoutingInfo (
156139 routingInfo : BaseRoutingInfo
157140) : routingInfo is StaticShardingRoutingInfo {
158- return routingInfo . isStaticSharding ;
141+ return routingInfo instanceof StaticShardingRoutingInfo ;
159142}
160143
161144export function createRoutingInfo (
0 commit comments