- Notifications
You must be signed in to change notification settings - Fork914
chore: send workspace pubsub events by owner id#14964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -24,6 +24,7 @@ import ( | ||
"github.com/coder/coder/v2/coderd/prometheusmetrics" | ||
"github.com/coder/coder/v2/coderd/tracing" | ||
"github.com/coder/coder/v2/coderd/workspacestats" | ||
"github.com/coder/coder/v2/coderd/wspubsub" | ||
"github.com/coder/coder/v2/codersdk" | ||
"github.com/coder/coder/v2/codersdk/agentsdk" | ||
"github.com/coder/coder/v2/tailnet" | ||
@@ -45,14 +46,15 @@ type API struct { | ||
*ScriptsAPI | ||
*tailnet.DRPCService | ||
mu sync.Mutex | ||
} | ||
var _ agentproto.DRPCAgentServer = &API{} | ||
type Options struct { | ||
AgentID uuid.UUID | ||
OwnerID uuid.UUID | ||
WorkspaceID uuid.UUID | ||
Ctx context.Context | ||
Log slog.Logger | ||
@@ -62,7 +64,7 @@ type Options struct { | ||
TailnetCoordinator *atomic.Pointer[tailnet.Coordinator] | ||
StatsReporter *workspacestats.Reporter | ||
AppearanceFetcher *atomic.Pointer[appearance.Fetcher] | ||
PublishWorkspaceUpdateFn func(ctx context.Context,userID uuid.UUID, event wspubsub.WorkspaceEvent) | ||
PublishWorkspaceAgentLogsUpdateFn func(ctx context.Context, workspaceAgentID uuid.UUID, msg agentsdk.LogsNotifyMessage) | ||
NetworkTelemetryHandler func(batch []*tailnetproto.TelemetryEvent) | ||
@@ -75,18 +77,13 @@ type Options struct { | ||
ExternalAuthConfigs []*externalauth.Config | ||
Experiments codersdk.Experiments | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This doesn't need to be optional anymore, presumably since we removed the v1 agent api. | ||
UpdateAgentMetricsFn func(ctx context.Context, labels prometheusmetrics.AgentMetricLabels, metrics []*agentproto.Stats_Metric) | ||
} | ||
func New(opts Options) *API { | ||
api := &API{ | ||
opts: opts, | ||
mu: sync.Mutex{}, | ||
} | ||
api.ManifestAPI = &ManifestAPI{ | ||
@@ -98,16 +95,7 @@ func New(opts Options) *API { | ||
AgentFn: api.agent, | ||
Database: opts.Database, | ||
DerpMapFn: opts.DerpMapFn, | ||
WorkspaceID: opts.WorkspaceID, | ||
} | ||
api.AnnouncementBannerAPI = &AnnouncementBannerAPI{ | ||
@@ -125,7 +113,7 @@ func New(opts Options) *API { | ||
api.LifecycleAPI = &LifecycleAPI{ | ||
AgentFn: api.agent, | ||
WorkspaceID: opts.WorkspaceID, | ||
Database: opts.Database, | ||
Log: opts.Log, | ||
PublishWorkspaceUpdateFn: api.publishWorkspaceUpdate, | ||
@@ -209,39 +197,11 @@ func (a *API) agent(ctx context.Context) (database.WorkspaceAgent, error) { | ||
return agent, nil | ||
} | ||
func (a *API) publishWorkspaceUpdate(ctx context.Context, agent *database.WorkspaceAgent, kind wspubsub.WorkspaceEventKind) error { | ||
a.opts.PublishWorkspaceUpdateFn(ctx, a.opts.OwnerID, wspubsub.WorkspaceEvent{ | ||
ethanndickson marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
Kind: kind, | ||
WorkspaceID: a.opts.WorkspaceID, | ||
AgentID: &agent.ID, | ||
}) | ||
return nil | ||
} |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.