forked from gitpod-io/gitpod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[server] Publish events in workspace starter - WEB-622 (gitpod-io#18234)
* [server] Publish events during workspace starter * add copy comment * retest * fix * fix * fix * fix * fix * retest * retest * try?
- Loading branch information
Showing
9 changed files
with
118 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright (c) 2023 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License.AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { inject, injectable } from "inversify"; | ||
import { log } from "@gitpod/gitpod-protocol/lib/util/logging"; | ||
import { | ||
PrebuildUpdatesChannel, | ||
RedisPrebuildUpdate, | ||
RedisWorkspaceInstanceUpdate, | ||
WorkspaceInstanceUpdatesChannel, | ||
} from "@gitpod/gitpod-protocol"; | ||
import { Redis } from "ioredis"; | ||
import { reportUpdatePublished } from "../prometheus-metrics"; | ||
|
||
@injectable() | ||
// RedisPublisher is a copy from ws-manager-bridge/src/redis/publisher.go until we find a better | ||
// way to share the publisher across packages. | ||
// WEB-621 | ||
export class RedisPublisher { | ||
constructor(@inject(Redis) private readonly client: Redis) {} | ||
|
||
async publishPrebuildUpdate(update: RedisPrebuildUpdate): Promise<void> { | ||
log.debug("[redis] Publish prebuild udpate invoked."); | ||
|
||
let err: Error | undefined; | ||
try { | ||
const serialized = JSON.stringify(update); | ||
await this.client.publish(PrebuildUpdatesChannel, serialized); | ||
log.debug("[redis] Succesfully published prebuild update.", update); | ||
} catch (e) { | ||
err = e; | ||
log.error("[redis] Failed to publish prebuild update.", e, update); | ||
} finally { | ||
reportUpdatePublished("prebuild", err); | ||
} | ||
} | ||
|
||
async publishInstanceUpdate(update: RedisWorkspaceInstanceUpdate): Promise<void> { | ||
let err: Error | undefined; | ||
try { | ||
const serialized = JSON.stringify(update); | ||
await this.client.publish(WorkspaceInstanceUpdatesChannel, serialized); | ||
log.debug("[redis] Succesfully published instance update.", update); | ||
} catch (e) { | ||
err = e; | ||
log.error("[redis] Failed to publish instance update.", e, update); | ||
} finally { | ||
reportUpdatePublished("workspace-instance", err); | ||
} | ||
} | ||
|
||
async publishHeadlessUpdate(): Promise<void> { | ||
log.debug("[redis] Publish headless udpate invoked."); | ||
reportUpdatePublished("headless"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters