internal/mcp: rename ClientConnection to ServerConnection
It's too confusing that you send server requests through the Client, and send client requests through the ClientConnection. Rename ClientConnection to ServerConnection, so that the types on the server side of the control diagram start with 'Server'. Change-Id: Idfd27af464a9296a2341cd23b2075cd9d0eb6b45 Reviewed-on: https://go-review.googlesource.com/c/tools/+/670538 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Robert Findley <rfindley@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
This commit is contained in:
parent
e0e304e51e
commit
347a1a0078
1 changed files with 65 additions and 63 deletions
|
|
@ -24,7 +24,7 @@ type hiParams struct {
|
|||
Name string
|
||||
}
|
||||
|
||||
func sayHi(ctx context.Context, cc *ClientConnection, v hiParams) ([]Content, error) {
|
||||
func sayHi(ctx context.Context, cc *ServerConnection, v hiParams) ([]Content, error) {
|
||||
if err := cc.Ping(ctx); err != nil {
|
||||
return nil, fmt.Errorf("ping failed: %v", err)
|
||||
}
|
||||
|
|
@ -43,13 +43,13 @@ func TestEndToEnd(t *testing.T) {
|
|||
// The 'fail' tool returns this error.
|
||||
failure := errors.New("mcp failure")
|
||||
s.AddTools(
|
||||
NewTool("fail", "just fail", func(context.Context, *ClientConnection, struct{}) ([]Content, error) {
|
||||
NewTool("fail", "just fail", func(context.Context, *ServerConnection, struct{}) ([]Content, error) {
|
||||
return nil, failure
|
||||
}),
|
||||
)
|
||||
|
||||
s.AddPrompts(
|
||||
NewPrompt("code_review", "do a code review", func(_ context.Context, _ *ClientConnection, params struct{ Code string }) (*protocol.GetPromptResult, error) {
|
||||
NewPrompt("code_review", "do a code review", func(_ context.Context, _ *ServerConnection, params struct{ Code string }) (*protocol.GetPromptResult, error) {
|
||||
return &protocol.GetPromptResult{
|
||||
Description: "Code review prompt",
|
||||
Messages: []protocol.PromptMessage{
|
||||
|
|
@ -57,7 +57,7 @@ func TestEndToEnd(t *testing.T) {
|
|||
},
|
||||
}, nil
|
||||
}),
|
||||
NewPrompt("fail", "", func(_ context.Context, _ *ClientConnection, params struct{}) (*protocol.GetPromptResult, error) {
|
||||
NewPrompt("fail", "", func(_ context.Context, _ *ServerConnection, params struct{}) (*protocol.GetPromptResult, error) {
|
||||
return nil, failure
|
||||
}),
|
||||
)
|
||||
|
|
@ -195,7 +195,7 @@ func TestEndToEnd(t *testing.T) {
|
|||
//
|
||||
// The caller should cancel either the client connection or server connection
|
||||
// when the connections are no longer needed.
|
||||
func basicConnection(t *testing.T, tools ...*Tool) (*ClientConnection, *Client) {
|
||||
func basicConnection(t *testing.T, tools ...*Tool) (*ServerConnection, *Client) {
|
||||
t.Helper()
|
||||
|
||||
ctx := context.Background()
|
||||
|
|
@ -283,7 +283,7 @@ func TestCancellation(t *testing.T) {
|
|||
cancelled = make(chan struct{}, 1) // don't block the request
|
||||
)
|
||||
|
||||
slowRequest := func(ctx context.Context, cc *ClientConnection, v struct{}) ([]Content, error) {
|
||||
slowRequest := func(ctx context.Context, cc *ServerConnection, v struct{}) ([]Content, error) {
|
||||
start <- struct{}{}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
|
|
|||
Loading…
Reference in a new issue