// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: agent/v1/service.proto

package agentv1connect

import (
	context "context"
	errors "errors"
	http "net/http"
	strings "strings"

	connect "connectrpc.com/connect"

	v1 "github.com/runmedev/runme/v3/api/gen/proto/go/agent/v1"
)

// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0

const (
	// MessagesServiceName is the fully-qualified name of the MessagesService service.
	MessagesServiceName = "agent.v1.MessagesService"
)

// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
	// MessagesServiceGenerateProcedure is the fully-qualified name of the MessagesService's Generate
	// RPC.
	MessagesServiceGenerateProcedure = "/agent.v1.MessagesService/Generate"
)

// MessagesServiceClient is a client for the agent.v1.MessagesService service.
type MessagesServiceClient interface {
	// Generate generates cells. Responses are streamed.
	Generate(context.Context, *connect.Request[v1.GenerateRequest]) (*connect.ServerStreamForClient[v1.GenerateResponse], error)
}

// NewMessagesServiceClient constructs a client for the agent.v1.MessagesService service. By
// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses,
// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
// connect.WithGRPC() or connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewMessagesServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) MessagesServiceClient {
	baseURL = strings.TrimRight(baseURL, "/")
	messagesServiceMethods := v1.File_agent_v1_service_proto.Services().ByName("MessagesService").Methods()
	return &messagesServiceClient{
		generate: connect.NewClient[v1.GenerateRequest, v1.GenerateResponse](
			httpClient,
			baseURL+MessagesServiceGenerateProcedure,
			connect.WithSchema(messagesServiceMethods.ByName("Generate")),
			connect.WithClientOptions(opts...),
		),
	}
}

// messagesServiceClient implements MessagesServiceClient.
type messagesServiceClient struct {
	generate *connect.Client[v1.GenerateRequest, v1.GenerateResponse]
}

// Generate calls agent.v1.MessagesService.Generate.
func (c *messagesServiceClient) Generate(ctx context.Context, req *connect.Request[v1.GenerateRequest]) (*connect.ServerStreamForClient[v1.GenerateResponse], error) {
	return c.generate.CallServerStream(ctx, req)
}

// MessagesServiceHandler is an implementation of the agent.v1.MessagesService service.
type MessagesServiceHandler interface {
	// Generate generates cells. Responses are streamed.
	Generate(context.Context, *connect.Request[v1.GenerateRequest], *connect.ServerStream[v1.GenerateResponse]) error
}

// NewMessagesServiceHandler builds an HTTP handler from the service implementation. It returns the
// path on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewMessagesServiceHandler(svc MessagesServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
	messagesServiceMethods := v1.File_agent_v1_service_proto.Services().ByName("MessagesService").Methods()
	messagesServiceGenerateHandler := connect.NewServerStreamHandler(
		MessagesServiceGenerateProcedure,
		svc.Generate,
		connect.WithSchema(messagesServiceMethods.ByName("Generate")),
		connect.WithHandlerOptions(opts...),
	)
	return "/agent.v1.MessagesService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		switch r.URL.Path {
		case MessagesServiceGenerateProcedure:
			messagesServiceGenerateHandler.ServeHTTP(w, r)
		default:
			http.NotFound(w, r)
		}
	})
}

// UnimplementedMessagesServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedMessagesServiceHandler struct{}

func (UnimplementedMessagesServiceHandler) Generate(context.Context, *connect.Request[v1.GenerateRequest], *connect.ServerStream[v1.GenerateResponse]) error {
	return connect.NewError(connect.CodeUnimplemented, errors.New("agent.v1.MessagesService.Generate is not implemented"))
}
