NewInMemoryCoordinatorClient creates a coordination client that uses channels to connect to a local Coordinator. (The typical alternative is a DRPC-based client.)
( logger slog.Logger, clientID uuid.UUID, auth CoordinateeAuth, coordinator Coordinator, )
| 610 | // NewInMemoryCoordinatorClient creates a coordination client that uses channels to connect to a |
| 611 | // local Coordinator. (The typical alternative is a DRPC-based client.) |
| 612 | func NewInMemoryCoordinatorClient( |
| 613 | logger slog.Logger, |
| 614 | clientID uuid.UUID, |
| 615 | auth CoordinateeAuth, |
| 616 | coordinator Coordinator, |
| 617 | ) CoordinatorClient { |
| 618 | logger = logger.With(slog.F("client_id", clientID)) |
| 619 | c := &inMemoryCoordClient{logger: logger} |
| 620 | c.ctx, c.cancel = context.WithCancel(context.Background()) |
| 621 | |
| 622 | // use the background context since we will depend exclusively on closing the req channel to |
| 623 | // tell the coordinator we are done. |
| 624 | c.reqs, c.resps = coordinator.Coordinate(context.Background(), |
| 625 | clientID, fmt.Sprintf("inmemory%s", clientID), |
| 626 | auth, |
| 627 | ) |
| 628 | return c |
| 629 | } |
| 630 | |
| 631 | type DERPMapSetter interface { |
| 632 | SetDERPMap(derpMap *tailcfg.DERPMap) |