Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfabe2d1

Browse files
committed
add pubsub to dbmem
1 parent28942f0 commitfabe2d1

File tree

5 files changed

+2
-138
lines changed

5 files changed

+2
-138
lines changed

‎cli/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,8 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
691691
varpubsubWatchdogTimeout<-chanstruct{}
692692
ifvals.InMemoryDatabase {
693693
// This is only used for testing.
694-
options.Database=dbmem.New()
695694
options.Pubsub=pubsub.NewInMemory()
695+
options.Database=dbmem.New()
696696
}else {
697697
sqlDB,dbURL,err:=getPostgresDB(ctx,logger,vals.PostgresURL.String(),codersdk.PostgresAuth(vals.PostgresAuth),sqlDriver)
698698
iferr!=nil {

‎coderd/database/dbmem/dbmem.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7776,7 +7776,7 @@ func (q *FakeQuerier) InsertWorkspace(_ context.Context, arg database.InsertWork
77767776
returnworkspace,nil
77777777
}
77787778

7779-
func (q*FakeQuerier)InsertWorkspaceAgent(_ context.Context,arg database.InsertWorkspaceAgentParams) (database.WorkspaceAgent,error) {
7779+
func (q*FakeQuerier)InsertWorkspaceAgent(ctx context.Context,arg database.InsertWorkspaceAgentParams) (database.WorkspaceAgent,error) {
77807780
iferr:=validateDatabaseType(arg);err!=nil {
77817781
return database.WorkspaceAgent{},err
77827782
}

‎coderd/database/dump.sql

Lines changed: 0 additions & 61 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
11
DROPTYPE agent_id_name_pair;
2-
3-
DROPTRIGGER IF EXISTS new_workspace_notifyON workspaces;
4-
DROPFUNCTION IF EXISTS new_workspace_notify;
5-
6-
DROPTRIGGER IF EXISTS new_agent_notifyON workspace_agents;
7-
DROPFUNCTION IF EXISTS new_agent_notify;

‎coderd/database/migrations/000260_workspace_updates.up.sql

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,3 @@ CREATE TYPE agent_id_name_pair AS (
22
id uuid,
33
nametext
44
);
5-
6-
CREATEFUNCTIONnew_workspace_notify() RETURNS trigger
7-
LANGUAGE plpgsql
8-
AS $$
9-
DECLARE
10-
BEGIN
11-
-- Notify for new workspaces & ownership transfers
12-
IF TG_OP='INSERT'OR (TG_OP='UPDATE'ANDNEW.owner_id<>OLD.owner_id) THEN
13-
-- Write to the notification channel `new_workspace:owner_id`
14-
-- with the workspace id as the payload.
15-
PERFORM pg_notify('new_workspace:'||NEW.owner_id,NEW.id::text);
16-
END IF;
17-
RETURN NEW;
18-
END;
19-
$$;
20-
21-
CREATETRIGGERnew_workspace_notify
22-
AFTER INSERTORUPDATEON workspaces
23-
FOR EACH ROW
24-
EXECUTE FUNCTION new_workspace_notify();
25-
26-
27-
CREATEFUNCTIONnew_agent_notify() RETURNS trigger
28-
LANGUAGE plpgsql
29-
AS $$
30-
DECLARE
31-
workspace_owner_id uuid;
32-
BEGIN
33-
SELECTworkspaces.owner_id
34-
INTO workspace_owner_id
35-
FROM
36-
workspaces
37-
WHERE
38-
workspaces.id= (
39-
SELECT
40-
workspace_id
41-
FROM
42-
workspace_builds
43-
WHERE
44-
workspace_builds.job_id= (
45-
SELECT
46-
job_id
47-
FROM
48-
workspace_resources
49-
WHERE
50-
workspace_resources.id= (
51-
SELECT
52-
resource_id
53-
FROM
54-
workspace_agents
55-
WHERE
56-
workspace_agents.id=NEW.id
57-
)
58-
)
59-
);
60-
-- Agents might not belong to a workspace (template imports)
61-
IF workspace_owner_idIS NOT NULL THEN
62-
-- Write to the notification channel `new_agent:workspace_owner_id`
63-
PERFORM pg_notify('new_agent:'|| workspace_owner_id,'');
64-
END IF;
65-
RETURN NEW;
66-
END;
67-
$$;
68-
69-
70-
CREATETRIGGERnew_agent_notify
71-
AFTER INSERTON workspace_agents
72-
FOR EACH ROW
73-
EXECUTE FUNCTION new_agent_notify();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp