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

chore: rename client Listen to ConnectRPC#11916

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

Merged
spikecurtis merged 1 commit intomainfromspike/10534-rename-listen
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletionsagent/agent.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,7 +88,7 @@ type Options struct {
}

type Client interface {
Listen(ctx context.Context) (drpc.Conn, error)
ConnectRPC(ctx context.Context) (drpc.Conn, error)
ReportStats(ctx context.Context, log slog.Logger, statsChan <-chan *agentsdk.Stats, setInterval func(time.Duration)) (io.Closer, error)
PostLifecycle(ctx context.Context, state agentsdk.PostLifecycleRequest) error
PostMetadata(ctx context.Context, req agentsdk.PostMetadataRequest) error
Expand DownExpand Up@@ -691,8 +691,8 @@ func (a *agent) run(ctx context.Context) error {
}
a.sessionToken.Store(&sessionToken)

//Listen returns the dRPC connection we use for the Agent v2+API
conn, err := a.client.Listen(ctx)
//ConnectRPC returns the dRPC connection we use for the Agentand Tailnetv2+APIs
conn, err := a.client.ConnectRPC(ctx)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletionagent/agenttest/client.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -99,7 +99,7 @@ func (c *Client) Close() {
c.derpMapOnce.Do(func() { close(c.derpMapUpdates) })
}

func (c *Client)Listen(ctx context.Context) (drpc.Conn, error) {
func (c *Client)ConnectRPC(ctx context.Context) (drpc.Conn, error) {
conn, lis := drpcsdk.MemTransportPipe()
c.LastWorkspaceAgent = func() {
_ = conn.Close()
Expand Down
14 changes: 7 additions & 7 deletionscoderd/workspaceagents_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,7 +319,7 @@ func TestWorkspaceAgentLogs(t *testing.T) {
})
}

funcTestWorkspaceAgentListen(t *testing.T) {
funcTestWorkspaceAgentConnectRPC(t *testing.T) {
t.Parallel()

t.Run("Connect", func(t *testing.T) {
Expand DownExpand Up@@ -400,7 +400,7 @@ func TestWorkspaceAgentListen(t *testing.T) {
agentClient := agentsdk.New(client.URL)
agentClient.SetSessionToken(authToken)

_, err = agentClient.Listen(ctx)
_, err = agentClient.ConnectRPC(ctx)
require.Error(t, err)
var sdkErr *codersdk.Error
require.ErrorAs(t, err, &sdkErr)
Expand DownExpand Up@@ -500,7 +500,7 @@ func TestWorkspaceAgentTailnetDirectDisabled(t *testing.T) {
// Verify that the manifest has DisableDirectConnections set to true.
agentClient := agentsdk.New(client.URL)
agentClient.SetSessionToken(r.AgentToken)
rpc, err := agentClient.Listen(ctx)
rpc, err := agentClient.ConnectRPC(ctx)
require.NoError(t, err)
defer func() {
cErr := rpc.Close()
Expand DownExpand Up@@ -830,7 +830,7 @@ func TestWorkspaceAgentAppHealth(t *testing.T) {

agentClient := agentsdk.New(client.URL)
agentClient.SetSessionToken(r.AgentToken)
conn, err := agentClient.Listen(ctx)
conn, err := agentClient.ConnectRPC(ctx)
require.NoError(t, err)
defer func() {
cErr := conn.Close()
Expand DownExpand Up@@ -1129,7 +1129,7 @@ func TestWorkspaceAgent_Metadata(t *testing.T) {
agentClient.SetSessionToken(r.AgentToken)

ctx := testutil.Context(t, testutil.WaitMedium)
conn, err := agentClient.Listen(ctx)
conn, err := agentClient.ConnectRPC(ctx)
require.NoError(t, err)
defer func() {
cErr := conn.Close()
Expand DownExpand Up@@ -1307,7 +1307,7 @@ func TestWorkspaceAgent_Metadata_CatchMemoryLeak(t *testing.T) {
agentClient.SetSessionToken(r.AgentToken)

ctx, cancel := context.WithCancel(testutil.Context(t, testutil.WaitSuperLong))
conn, err := agentClient.Listen(ctx)
conn, err := agentClient.ConnectRPC(ctx)
require.NoError(t, err)
defer func() {
cErr := conn.Close()
Expand DownExpand Up@@ -1669,7 +1669,7 @@ func requireGetManifest(ctx context.Context, t testing.TB, aAPI agentproto.DRPCA
}

func postStartup(ctx context.Context, t testing.TB, client agent.Client, startup *agentproto.Startup) error {
conn, err := client.Listen(ctx)
conn, err := client.ConnectRPC(ctx)
require.NoError(t, err)
defer func() {
cErr := conn.Close()
Expand Down
2 changes: 1 addition & 1 deletioncoderd/workspaceapps/apptest/setup.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -398,7 +398,7 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
primaryAppHost, err := client.AppHost(appHostCtx)
require.NoError(t, err)
if primaryAppHost.Host != "" {
rpcConn, err := agentClient.Listen(appHostCtx)
rpcConn, err := agentClient.ConnectRPC(appHostCtx)
require.NoError(t, err)
aAPI := agentproto.NewDRPCAgentClient(rpcConn)
manifest, err := aAPI.GetManifest(appHostCtx, &agentproto.GetManifestRequest{})
Expand Down
7 changes: 3 additions & 4 deletionscodersdk/agentsdk/agentsdk.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -171,9 +171,8 @@ func (c *Client) RewriteDERPMap(derpMap *tailcfg.DERPMap) {
}
}

// Listen connects to the workspace agent API WebSocket
// that handles connection negotiation.
func (c *Client) Listen(ctx context.Context) (drpc.Conn, error) {
// ConnectRPC connects to the workspace agent API and tailnet API
func (c *Client) ConnectRPC(ctx context.Context) (drpc.Conn, error) {
rpcURL, err := c.SDK.URL.Parse("/api/v2/workspaceagents/me/rpc")
if err != nil {
return nil, xerrors.Errorf("parse url: %w", err)
Expand DownExpand Up@@ -210,7 +209,7 @@ func (c *Client) Listen(ctx context.Context) (drpc.Conn, error) {
netConn := &closeNetConn{
Conn: wsNetConn,
closeFunc: func() {
_ = conn.Close(websocket.StatusGoingAway, "Listen closed")
_ = conn.Close(websocket.StatusGoingAway, "ConnectRPC closed")
},
}
config := yamux.DefaultConfig()
Expand Down
2 changes: 1 addition & 1 deletionenterprise/coderd/appearance_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -176,7 +176,7 @@ func TestServiceBanners(t *testing.T) {
}

func requireGetServiceBanner(ctx context.Context, t *testing.T, client *agentsdk.Client) codersdk.ServiceBannerConfig {
cc, err := client.Listen(ctx)
cc, err := client.ConnectRPC(ctx)
require.NoError(t, err)
defer func() {
_ = cc.Close()
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp