@@ -15,6 +15,7 @@ import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
15
15
import { TraceContext } from "@gitpod/gitpod-protocol/lib/util/tracing" ;
16
16
import { inject , injectable } from "inversify" ;
17
17
import { MessageBusIntegration } from "../workspace/messagebus-integration" ;
18
+ import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server" ;
18
19
19
20
export interface PrebuildUpdateListener {
20
21
( ctx : TraceContext , evt : PrebuildWithStatus ) : void ;
@@ -69,7 +70,12 @@ export class LocalRabbitMQBackedMessageBroker implements LocalMessageBroker {
69
70
this . disposables . push (
70
71
this . messageBusIntegration . listenForPrebuildUpdates (
71
72
undefined ,
72
- ( ctx : TraceContext , update : PrebuildWithStatus ) => {
73
+ async ( ctx : TraceContext , update : PrebuildWithStatus ) => {
74
+ const enabled = await this . isRedisPubSubByTypeEnabled ( "prebuild" ) ;
75
+ if ( enabled ) {
76
+ log . debug ( "[messagebus] Prebuild listener is disabled through feature flag" ) ;
77
+ return ;
78
+ }
73
79
TraceContext . setOWI ( ctx , { workspaceId : update . info . buildWorkspaceId } ) ;
74
80
75
81
const listeners = this . prebuildUpdateListeners . get ( update . info . projectId ) || [ ] ;
@@ -91,7 +97,12 @@ export class LocalRabbitMQBackedMessageBroker implements LocalMessageBroker {
91
97
) ;
92
98
this . disposables . push (
93
99
this . messageBusIntegration . listenForPrebuildUpdatableQueue (
94
- ( ctx : TraceContext , evt : HeadlessWorkspaceEvent ) => {
100
+ async ( ctx : TraceContext , evt : HeadlessWorkspaceEvent ) => {
101
+ const enabled = await this . isRedisPubSubByTypeEnabled ( "prebuild-updatable" ) ;
102
+ if ( enabled ) {
103
+ log . debug ( "[messagebus] Prebuild updatable listener is disabled through feature flag" ) ;
104
+ return ;
105
+ }
95
106
TraceContext . setOWI ( ctx , { workspaceId : evt . workspaceID } ) ;
96
107
97
108
const listeners =
@@ -110,7 +121,13 @@ export class LocalRabbitMQBackedMessageBroker implements LocalMessageBroker {
110
121
this . disposables . push (
111
122
this . messageBusIntegration . listenForWorkspaceInstanceUpdates (
112
123
undefined ,
113
- ( ctx : TraceContext , instance : WorkspaceInstance , userId : string | undefined ) => {
124
+ async ( ctx : TraceContext , instance : WorkspaceInstance , userId : string | undefined ) => {
125
+ const enabled = await this . isRedisPubSubByTypeEnabled ( "workspace-instance" ) ;
126
+ if ( enabled ) {
127
+ log . debug ( "[messagebus] Workspace instance listner is disabled through feature flag" ) ;
128
+ return ;
129
+ }
130
+
114
131
TraceContext . setOWI ( ctx , { userId, instanceId : instance . id } ) ;
115
132
116
133
if ( ! userId ) {
@@ -170,4 +187,15 @@ export class LocalRabbitMQBackedMessageBroker implements LocalMessageBroker {
170
187
}
171
188
} ) ;
172
189
}
190
+
191
+ private async isRedisPubSubByTypeEnabled (
192
+ type : "workspace-instance" | "prebuild" | "prebuild-updatable" ,
193
+ ) : Promise < boolean > {
194
+ const enabledTypes = await getExperimentsClientForBackend ( ) . getValueAsync (
195
+ "enableRedisPubSubByUpdateType" ,
196
+ "none" ,
197
+ { } ,
198
+ ) ;
199
+ return enabledTypes . indexOf ( type ) >= 0 ;
200
+ }
173
201
}
0 commit comments