mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 03:39:39 +00:00
139 lines
5.6 KiB
Go
139 lines
5.6 KiB
Go
//go:build grpc
|
|
|
|
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
|
//
|
|
// Source: xsvm/service.proto
|
|
|
|
package xsvmconnect
|
|
|
|
import (
|
|
connect "connectrpc.com/connect"
|
|
context "context"
|
|
errors "errors"
|
|
xsvm "github.com/luxfi/node/connectproto/pb/xsvm"
|
|
http "net/http"
|
|
strings "strings"
|
|
)
|
|
|
|
// 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 (
|
|
// PingName is the fully-qualified name of the Ping service.
|
|
PingName = "xsvm.Ping"
|
|
)
|
|
|
|
// 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 (
|
|
// PingPingProcedure is the fully-qualified name of the Ping's Ping RPC.
|
|
PingPingProcedure = "/xsvm.Ping/Ping"
|
|
// PingStreamPingProcedure is the fully-qualified name of the Ping's StreamPing RPC.
|
|
PingStreamPingProcedure = "/xsvm.Ping/StreamPing"
|
|
)
|
|
|
|
// PingClient is a client for the xsvm.Ping service.
|
|
type PingClient interface {
|
|
Ping(context.Context, *connect.Request[xsvm.PingRequest]) (*connect.Response[xsvm.PingReply], error)
|
|
StreamPing(context.Context) *connect.BidiStreamForClient[xsvm.StreamPingRequest, xsvm.StreamPingReply]
|
|
}
|
|
|
|
// NewPingClient constructs a client for the xsvm.Ping 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 NewPingClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) PingClient {
|
|
baseURL = strings.TrimRight(baseURL, "/")
|
|
pingMethods := xsvm.File_xsvm_service_proto.Services().ByName("Ping").Methods()
|
|
return &pingClient{
|
|
ping: connect.NewClient[xsvm.PingRequest, xsvm.PingReply](
|
|
httpClient,
|
|
baseURL+PingPingProcedure,
|
|
connect.WithSchema(pingMethods.ByName("Ping")),
|
|
connect.WithClientOptions(opts...),
|
|
),
|
|
streamPing: connect.NewClient[xsvm.StreamPingRequest, xsvm.StreamPingReply](
|
|
httpClient,
|
|
baseURL+PingStreamPingProcedure,
|
|
connect.WithSchema(pingMethods.ByName("StreamPing")),
|
|
connect.WithClientOptions(opts...),
|
|
),
|
|
}
|
|
}
|
|
|
|
// pingClient implements PingClient.
|
|
type pingClient struct {
|
|
ping *connect.Client[xsvm.PingRequest, xsvm.PingReply]
|
|
streamPing *connect.Client[xsvm.StreamPingRequest, xsvm.StreamPingReply]
|
|
}
|
|
|
|
// Ping calls xsvm.Ping.Ping.
|
|
func (c *pingClient) Ping(ctx context.Context, req *connect.Request[xsvm.PingRequest]) (*connect.Response[xsvm.PingReply], error) {
|
|
return c.ping.CallUnary(ctx, req)
|
|
}
|
|
|
|
// StreamPing calls xsvm.Ping.StreamPing.
|
|
func (c *pingClient) StreamPing(ctx context.Context) *connect.BidiStreamForClient[xsvm.StreamPingRequest, xsvm.StreamPingReply] {
|
|
return c.streamPing.CallBidiStream(ctx)
|
|
}
|
|
|
|
// PingHandler is an implementation of the xsvm.Ping service.
|
|
type PingHandler interface {
|
|
Ping(context.Context, *connect.Request[xsvm.PingRequest]) (*connect.Response[xsvm.PingReply], error)
|
|
StreamPing(context.Context, *connect.BidiStream[xsvm.StreamPingRequest, xsvm.StreamPingReply]) error
|
|
}
|
|
|
|
// NewPingHandler 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 NewPingHandler(svc PingHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
|
pingMethods := xsvm.File_xsvm_service_proto.Services().ByName("Ping").Methods()
|
|
pingPingHandler := connect.NewUnaryHandler(
|
|
PingPingProcedure,
|
|
svc.Ping,
|
|
connect.WithSchema(pingMethods.ByName("Ping")),
|
|
connect.WithHandlerOptions(opts...),
|
|
)
|
|
pingStreamPingHandler := connect.NewBidiStreamHandler(
|
|
PingStreamPingProcedure,
|
|
svc.StreamPing,
|
|
connect.WithSchema(pingMethods.ByName("StreamPing")),
|
|
connect.WithHandlerOptions(opts...),
|
|
)
|
|
return "/xsvm.Ping/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
switch r.URL.Path {
|
|
case PingPingProcedure:
|
|
pingPingHandler.ServeHTTP(w, r)
|
|
case PingStreamPingProcedure:
|
|
pingStreamPingHandler.ServeHTTP(w, r)
|
|
default:
|
|
http.NotFound(w, r)
|
|
}
|
|
})
|
|
}
|
|
|
|
// UnimplementedPingHandler returns CodeUnimplemented from all methods.
|
|
type UnimplementedPingHandler struct{}
|
|
|
|
func (UnimplementedPingHandler) Ping(context.Context, *connect.Request[xsvm.PingRequest]) (*connect.Response[xsvm.PingReply], error) {
|
|
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("xsvm.Ping.Ping is not implemented"))
|
|
}
|
|
|
|
func (UnimplementedPingHandler) StreamPing(context.Context, *connect.BidiStream[xsvm.StreamPingRequest, xsvm.StreamPingReply]) error {
|
|
return connect.NewError(connect.CodeUnimplemented, errors.New("xsvm.Ping.StreamPing is not implemented"))
|
|
}
|