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

Commitf44448c

Browse files
committed
Rename context to more accurately reflect the contexts use case
Signed-off-by: Callum Styan <callumstyan@gmail.com>
1 parent25bdbc9 commitf44448c

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

‎coderd/agentapi/api.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
"github.com/coder/quartz"
3737
)
3838

39-
constworkspaceCacheRefreshInterval=5*time.Minute
39+
constworkspaceCacheRefreshInterval=1*time.Minute
4040

4141
// API implements the DRPC agent API interface from agent/proto. This struct is
4242
// instantiated once per agent connection and kept alive for the duration of the
@@ -69,7 +69,7 @@ type Options struct {
6969
WorkspaceID uuid.UUID
7070
OrganizationID uuid.UUID
7171

72-
Ctx context.Context
72+
AuthenticatedCtx context.Context
7373
Log slog.Logger
7474
Clock quartz.Clock
7575
Database database.Store
@@ -220,7 +220,7 @@ func New(opts Options, workspace database.Workspace) *API {
220220

221221
// Start background cache refresh loop to handle workspace changes
222222
// like prebuild claims where owner_id and other fields may be modified in the DB.
223-
goapi.startCacheRefreshLoop(opts.Ctx)
223+
goapi.startCacheRefreshLoop(opts.AuthenticatedCtx)
224224

225225
returnapi
226226
}
@@ -275,6 +275,7 @@ func (a *API) agent(ctx context.Context) (database.WorkspaceAgent, error) {
275275
// This ensures that changes like prebuild claims (which modify owner_id, name, etc.)
276276
// are eventually reflected in the cache without requiring agent reconnection.
277277
func (a*API)refreshCachedWorkspace(ctx context.Context) {
278+
a.opts.Log.Debug(ctx,"refreshing cached workspace",slog.F("test","test"))
278279
ws,err:=a.opts.Database.GetWorkspaceByID(ctx,a.opts.WorkspaceID)
279280
iferr!=nil {
280281
a.opts.Log.Warn(ctx,"failed to refresh cached workspace fields",slog.Error(err))

‎coderd/agentapi/metadata_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ func TestBatchUpdateMetadata(t *testing.T) {
671671

672672
// Create full API with cached workspace fields (initial state)
673673
api:=agentapi.New(agentapi.Options{
674-
Ctx:ctxWithActor,
674+
AuthenticatedCtx:ctxWithActor,
675675
AgentID:agentID,
676676
WorkspaceID:workspaceID,
677677
OwnerID:ownerID,

‎coderd/workspaceagentsrpc.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (api *API) workspaceAgentRPC(rw http.ResponseWriter, r *http.Request) {
132132
WorkspaceID:workspace.ID,
133133
OrganizationID:workspace.OrganizationID,
134134

135-
Ctx:ctx,
135+
AuthenticatedCtx:ctx,
136136
Log:logger,
137137
Clock:api.Clock,
138138
Database:api.Database,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp