-
Notifications
You must be signed in to change notification settings - Fork 421
Expand file tree
/
Copy pathsql.connect.go
More file actions
212 lines (190 loc) · 11.2 KB
/
sql.connect.go
File metadata and controls
212 lines (190 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: redpanda/api/dataplane/v1alpha3/sql.proto
package dataplanev1alpha3connect
import (
context "context"
errors "errors"
http "net/http"
strings "strings"
connect "connectrpc.com/connect"
v1alpha3 "github.com/redpanda-data/console/backend/pkg/protogen/redpanda/api/dataplane/v1alpha3"
)
// 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 (
// SQLServiceName is the fully-qualified name of the SQLService service.
SQLServiceName = "redpanda.api.dataplane.v1alpha3.SQLService"
)
// 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 (
// SQLServiceListCatalogsProcedure is the fully-qualified name of the SQLService's ListCatalogs RPC.
SQLServiceListCatalogsProcedure = "/redpanda.api.dataplane.v1alpha3.SQLService/ListCatalogs"
// SQLServiceListTablesProcedure is the fully-qualified name of the SQLService's ListTables RPC.
SQLServiceListTablesProcedure = "/redpanda.api.dataplane.v1alpha3.SQLService/ListTables"
// SQLServiceDescribeTableProcedure is the fully-qualified name of the SQLService's DescribeTable
// RPC.
SQLServiceDescribeTableProcedure = "/redpanda.api.dataplane.v1alpha3.SQLService/DescribeTable"
// SQLServiceExecuteQueryProcedure is the fully-qualified name of the SQLService's ExecuteQuery RPC.
SQLServiceExecuteQueryProcedure = "/redpanda.api.dataplane.v1alpha3.SQLService/ExecuteQuery"
)
// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package.
var (
sQLServiceServiceDescriptor = v1alpha3.File_redpanda_api_dataplane_v1alpha3_sql_proto.Services().ByName("SQLService")
sQLServiceListCatalogsMethodDescriptor = sQLServiceServiceDescriptor.Methods().ByName("ListCatalogs")
sQLServiceListTablesMethodDescriptor = sQLServiceServiceDescriptor.Methods().ByName("ListTables")
sQLServiceDescribeTableMethodDescriptor = sQLServiceServiceDescriptor.Methods().ByName("DescribeTable")
sQLServiceExecuteQueryMethodDescriptor = sQLServiceServiceDescriptor.Methods().ByName("ExecuteQuery")
)
// SQLServiceClient is a client for the redpanda.api.dataplane.v1alpha3.SQLService service.
type SQLServiceClient interface {
// ListCatalogs lists all catalogs visible to the caller.
ListCatalogs(context.Context, *connect.Request[v1alpha3.ListCatalogsRequest]) (*connect.Response[v1alpha3.ListCatalogsResponse], error)
// ListTables lists tables in a catalog.
ListTables(context.Context, *connect.Request[v1alpha3.ListTablesRequest]) (*connect.Response[v1alpha3.ListTablesResponse], error)
// DescribeTable returns metadata and column shape for a single table.
DescribeTable(context.Context, *connect.Request[v1alpha3.DescribeTableRequest]) (*connect.Response[v1alpha3.DescribeTableResponse], error)
// ExecuteQuery runs a single SQL statement. Rows returned are capped
// server-side; `truncated` indicates the cap fired.
ExecuteQuery(context.Context, *connect.Request[v1alpha3.ExecuteQueryRequest]) (*connect.Response[v1alpha3.ExecuteQueryResponse], error)
}
// NewSQLServiceClient constructs a client for the redpanda.api.dataplane.v1alpha3.SQLService
// 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 NewSQLServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) SQLServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
return &sQLServiceClient{
listCatalogs: connect.NewClient[v1alpha3.ListCatalogsRequest, v1alpha3.ListCatalogsResponse](
httpClient,
baseURL+SQLServiceListCatalogsProcedure,
connect.WithSchema(sQLServiceListCatalogsMethodDescriptor),
connect.WithClientOptions(opts...),
),
listTables: connect.NewClient[v1alpha3.ListTablesRequest, v1alpha3.ListTablesResponse](
httpClient,
baseURL+SQLServiceListTablesProcedure,
connect.WithSchema(sQLServiceListTablesMethodDescriptor),
connect.WithClientOptions(opts...),
),
describeTable: connect.NewClient[v1alpha3.DescribeTableRequest, v1alpha3.DescribeTableResponse](
httpClient,
baseURL+SQLServiceDescribeTableProcedure,
connect.WithSchema(sQLServiceDescribeTableMethodDescriptor),
connect.WithClientOptions(opts...),
),
executeQuery: connect.NewClient[v1alpha3.ExecuteQueryRequest, v1alpha3.ExecuteQueryResponse](
httpClient,
baseURL+SQLServiceExecuteQueryProcedure,
connect.WithSchema(sQLServiceExecuteQueryMethodDescriptor),
connect.WithClientOptions(opts...),
),
}
}
// sQLServiceClient implements SQLServiceClient.
type sQLServiceClient struct {
listCatalogs *connect.Client[v1alpha3.ListCatalogsRequest, v1alpha3.ListCatalogsResponse]
listTables *connect.Client[v1alpha3.ListTablesRequest, v1alpha3.ListTablesResponse]
describeTable *connect.Client[v1alpha3.DescribeTableRequest, v1alpha3.DescribeTableResponse]
executeQuery *connect.Client[v1alpha3.ExecuteQueryRequest, v1alpha3.ExecuteQueryResponse]
}
// ListCatalogs calls redpanda.api.dataplane.v1alpha3.SQLService.ListCatalogs.
func (c *sQLServiceClient) ListCatalogs(ctx context.Context, req *connect.Request[v1alpha3.ListCatalogsRequest]) (*connect.Response[v1alpha3.ListCatalogsResponse], error) {
return c.listCatalogs.CallUnary(ctx, req)
}
// ListTables calls redpanda.api.dataplane.v1alpha3.SQLService.ListTables.
func (c *sQLServiceClient) ListTables(ctx context.Context, req *connect.Request[v1alpha3.ListTablesRequest]) (*connect.Response[v1alpha3.ListTablesResponse], error) {
return c.listTables.CallUnary(ctx, req)
}
// DescribeTable calls redpanda.api.dataplane.v1alpha3.SQLService.DescribeTable.
func (c *sQLServiceClient) DescribeTable(ctx context.Context, req *connect.Request[v1alpha3.DescribeTableRequest]) (*connect.Response[v1alpha3.DescribeTableResponse], error) {
return c.describeTable.CallUnary(ctx, req)
}
// ExecuteQuery calls redpanda.api.dataplane.v1alpha3.SQLService.ExecuteQuery.
func (c *sQLServiceClient) ExecuteQuery(ctx context.Context, req *connect.Request[v1alpha3.ExecuteQueryRequest]) (*connect.Response[v1alpha3.ExecuteQueryResponse], error) {
return c.executeQuery.CallUnary(ctx, req)
}
// SQLServiceHandler is an implementation of the redpanda.api.dataplane.v1alpha3.SQLService service.
type SQLServiceHandler interface {
// ListCatalogs lists all catalogs visible to the caller.
ListCatalogs(context.Context, *connect.Request[v1alpha3.ListCatalogsRequest]) (*connect.Response[v1alpha3.ListCatalogsResponse], error)
// ListTables lists tables in a catalog.
ListTables(context.Context, *connect.Request[v1alpha3.ListTablesRequest]) (*connect.Response[v1alpha3.ListTablesResponse], error)
// DescribeTable returns metadata and column shape for a single table.
DescribeTable(context.Context, *connect.Request[v1alpha3.DescribeTableRequest]) (*connect.Response[v1alpha3.DescribeTableResponse], error)
// ExecuteQuery runs a single SQL statement. Rows returned are capped
// server-side; `truncated` indicates the cap fired.
ExecuteQuery(context.Context, *connect.Request[v1alpha3.ExecuteQueryRequest]) (*connect.Response[v1alpha3.ExecuteQueryResponse], error)
}
// NewSQLServiceHandler 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 NewSQLServiceHandler(svc SQLServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
sQLServiceListCatalogsHandler := connect.NewUnaryHandler(
SQLServiceListCatalogsProcedure,
svc.ListCatalogs,
connect.WithSchema(sQLServiceListCatalogsMethodDescriptor),
connect.WithHandlerOptions(opts...),
)
sQLServiceListTablesHandler := connect.NewUnaryHandler(
SQLServiceListTablesProcedure,
svc.ListTables,
connect.WithSchema(sQLServiceListTablesMethodDescriptor),
connect.WithHandlerOptions(opts...),
)
sQLServiceDescribeTableHandler := connect.NewUnaryHandler(
SQLServiceDescribeTableProcedure,
svc.DescribeTable,
connect.WithSchema(sQLServiceDescribeTableMethodDescriptor),
connect.WithHandlerOptions(opts...),
)
sQLServiceExecuteQueryHandler := connect.NewUnaryHandler(
SQLServiceExecuteQueryProcedure,
svc.ExecuteQuery,
connect.WithSchema(sQLServiceExecuteQueryMethodDescriptor),
connect.WithHandlerOptions(opts...),
)
return "/redpanda.api.dataplane.v1alpha3.SQLService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case SQLServiceListCatalogsProcedure:
sQLServiceListCatalogsHandler.ServeHTTP(w, r)
case SQLServiceListTablesProcedure:
sQLServiceListTablesHandler.ServeHTTP(w, r)
case SQLServiceDescribeTableProcedure:
sQLServiceDescribeTableHandler.ServeHTTP(w, r)
case SQLServiceExecuteQueryProcedure:
sQLServiceExecuteQueryHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedSQLServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedSQLServiceHandler struct{}
func (UnimplementedSQLServiceHandler) ListCatalogs(context.Context, *connect.Request[v1alpha3.ListCatalogsRequest]) (*connect.Response[v1alpha3.ListCatalogsResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("redpanda.api.dataplane.v1alpha3.SQLService.ListCatalogs is not implemented"))
}
func (UnimplementedSQLServiceHandler) ListTables(context.Context, *connect.Request[v1alpha3.ListTablesRequest]) (*connect.Response[v1alpha3.ListTablesResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("redpanda.api.dataplane.v1alpha3.SQLService.ListTables is not implemented"))
}
func (UnimplementedSQLServiceHandler) DescribeTable(context.Context, *connect.Request[v1alpha3.DescribeTableRequest]) (*connect.Response[v1alpha3.DescribeTableResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("redpanda.api.dataplane.v1alpha3.SQLService.DescribeTable is not implemented"))
}
func (UnimplementedSQLServiceHandler) ExecuteQuery(context.Context, *connect.Request[v1alpha3.ExecuteQueryRequest]) (*connect.Response[v1alpha3.ExecuteQueryResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("redpanda.api.dataplane.v1alpha3.SQLService.ExecuteQuery is not implemented"))
}