Skip to content

Commit 25f2abf

Browse files
authored
chore: remove tailnet from agent API and rename client API to tailnet (#11303)
Refactors our DRPC service definitions slightly. In the previous version, I inserted the RPCs from the tailnet proto directly into the Agent service. This makes things hard to deal with because DRPC then generates a new set of methods with new interfaces with the `DRPCAgent_` prefixed. Since you can't have a single method that takes different argument types, we couldn't reuse the implementation of those RFCs without a lot of extra classes and pass-thru methods. Instead, the "right" way to do it is to integrate at the DRPC layer. So, we have two DRPC services available over the Agent websocket, and register them both on the DRPC `mux`. Since the tailnet proto RPC service is now for both clients and agents, I renamed some things to clarify and shorten. This PR also removes the `TailnetAPI` implementation from the `agentapi` package, and the next PR in the stack replaces it with the implementation from the `tailnet` package.
1 parent 6529099 commit 25f2abf

File tree

11 files changed

+97
-328
lines changed

11 files changed

+97
-328
lines changed

agent/proto/agent.pb.go

Lines changed: 15 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

agent/proto/agent.proto

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,4 @@ service Agent {
256256
rpc UpdateStartup(UpdateStartupRequest) returns (Startup);
257257
rpc BatchUpdateMetadata(BatchUpdateMetadataRequest) returns (BatchUpdateMetadataResponse);
258258
rpc BatchCreateLogs(BatchCreateLogsRequest) returns (BatchCreateLogsResponse);
259-
260-
rpc StreamDERPMaps(tailnet.v2.StreamDERPMapsRequest) returns (stream tailnet.v2.DERPMap);
261-
rpc CoordinateTailnet(stream tailnet.v2.CoordinateRequest) returns (stream tailnet.v2.CoordinateResponse);
262259
}

agent/proto/agent_drpc.pb.go

Lines changed: 1 addition & 149 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/agentapi/api.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ type API struct {
4242
*AppsAPI
4343
*MetadataAPI
4444
*LogsAPI
45-
*TailnetAPI
4645

4746
mu sync.Mutex
4847
cachedWorkspaceID uuid.UUID
@@ -146,12 +145,6 @@ func New(opts Options) *API {
146145
PublishWorkspaceAgentLogsUpdateFn: opts.PublishWorkspaceAgentLogsUpdateFn,
147146
}
148147

149-
api.TailnetAPI = &TailnetAPI{
150-
Ctx: opts.Ctx,
151-
DerpMapFn: opts.DerpMapFn,
152-
DerpMapUpdateFrequency: opts.DerpMapUpdateFrequency,
153-
}
154-
155148
return api
156149
}
157150

coderd/agentapi/tailnet.go

Lines changed: 0 additions & 53 deletions
This file was deleted.

tailnet/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import (
1111
"github.com/coder/coder/v2/tailnet/proto"
1212
)
1313

14-
func NewDRPCClient(conn net.Conn) (proto.DRPCClientClient, error) {
14+
func NewDRPCClient(conn net.Conn) (proto.DRPCTailnetClient, error) {
1515
config := yamux.DefaultConfig()
1616
config.LogOutput = io.Discard
1717
session, err := yamux.Client(conn, config)
1818
if err != nil {
1919
return nil, xerrors.Errorf("multiplex client: %w", err)
2020
}
21-
return proto.NewDRPCClientClient(drpc.MultiplexedConn(session)), nil
21+
return proto.NewDRPCTailnetClient(drpc.MultiplexedConn(session)), nil
2222
}

0 commit comments

Comments
 (0)