From 98d798e0e170a2c59601158a7e845bfc8b776b94 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 4 Aug 2024 07:30:53 -0700 Subject: [PATCH 01/31] Adding Protobuf contract for callbacks: initial work --- go.mod | 3 +- go.sum | 2 + pkg/callbacks/httpclient/httpclient.go | 74 ++++ pkg/callbacks/httpclient/httpclient_test.go | 211 ++++++++--- pkg/callbacks/sql/sql.go | 106 ++++++ pkg/callbacks/sql/sql_test.go | 396 ++++++++++++++------ 6 files changed, 632 insertions(+), 160 deletions(-) diff --git a/go.mod b/go.mod index 81ca2e5c..5c4e617b 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/lib/pq v1.10.9 github.com/madflojo/tasks v1.2.0 github.com/madflojo/testcerts v1.2.0 + github.com/planetscale/vtprotobuf v0.6.0 github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 github.com/prometheus/client_golang v1.19.1 github.com/sirupsen/logrus v1.9.3 @@ -21,6 +22,7 @@ require ( github.com/tarmac-project/wapc-toolkit/callbacks v0.2.0 github.com/tarmac-project/wapc-toolkit/engine v0.2.0 github.com/wapc/wapc-go v0.7.0 + google.golang.org/protobuf v1.33.0 ) require ( @@ -115,7 +117,6 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c // indirect google.golang.org/grpc v1.62.1 // indirect - google.golang.org/protobuf v1.33.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index bbf70a08..a40d275a 100644 --- a/go.sum +++ b/go.sum @@ -254,6 +254,8 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/planetscale/vtprotobuf v0.6.0 h1:nBeETjudeJ5ZgBHUz1fVHvbqUKnYOXNhsIEabROxmNA= +github.com/planetscale/vtprotobuf v0.6.0/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/pkg/callbacks/httpclient/httpclient.go b/pkg/callbacks/httpclient/httpclient.go index 52430253..e304e695 100644 --- a/pkg/callbacks/httpclient/httpclient.go +++ b/pkg/callbacks/httpclient/httpclient.go @@ -28,6 +28,8 @@ import ( "github.com/pquerna/ffjson/ffjson" "github.com/tarmac-project/tarmac" + "github.com/tarmac-project/tarmac/proto" + pb "google.golang.org/protobuf/proto" ) // HTTPClient provides access to Host Callbacks that interact with an HTTP client. These callbacks offer all of the logic @@ -50,6 +52,78 @@ func New(_ Config) (*HTTPClient, error) { // base64 decoding of payload data are all handled via this function. Note, this function expects the // HTTPClientRequest JSON type as input and will return a KVStoreGetResponse JSON. func (hc *HTTPClient) Call(b []byte) ([]byte, error) { + // Parse incoming Request + msg := &proto.HTTPClient{} + err := pb.Unmarshal(b, msg) + if err != nil { + // Assume JSON for backwards compatibility + return hc.callJSON(b) + } + + // Create HTTPClientResponse + r := &proto.HTTPClientResponse{} + r.Status = &proto.Status{Code: 200, Status: "OK"} + + // Create HTTP Client + var request *http.Request + var c *http.Client + tr := &http.Transport{} + if msg.Insecure { + tr.TLSClientConfig = &tls.Config{ + InsecureSkipVerify: true, + } + } + c = &http.Client{Transport: tr} + + // Create HTTP Request + request, err = http.NewRequest(msg.Method, msg.Url, bytes.NewBuffer(msg.Body)) + if err != nil { + r.Status.Code = 400 + r.Status.Status = fmt.Sprintf("Unable to create HTTP request - %s", err) + } + + // Set user-supplied headers + for k, v := range msg.Headers { + request.Header.Set(k, v) + } + + // Execute HTTP Call + response, err := c.Do(request) + if err != nil { + r.Status.Code = 500 + r.Status.Status = fmt.Sprintf("Unable to execute HTTP request - %s", err) + } + + // Populate Response with Response + if response != nil { // nolint + defer response.Body.Close() + r.Code = int32(response.StatusCode) + r.Headers = make(map[string]string) + for k := range response.Header { + r.Headers[strings.ToLower(k)] = response.Header.Get(k) + } + body, err := io.ReadAll(response.Body) + if err != nil { + r.Status.Code = 500 + r.Status.Status = fmt.Sprintf("Unexpected error reading HTTP response body - %s", err) + } + r.Body = body + } + + // Marshal a response to return to caller + rsp, err := pb.Marshal(r) + if err != nil { + return []byte(""), fmt.Errorf("unable to marshal HTTPClient:call response") + } + + // Return response to caller + if r.Status.Code == 200 { + return rsp, nil + } + return rsp, fmt.Errorf("%s", r.Status.Status) +} + +func (he *HTTPClient) callJSON(b []byte) ([]byte, error) { // Start Response Message assuming everything is good r := tarmac.HTTPClientResponse{} r.Status.Code = 200 diff --git a/pkg/callbacks/httpclient/httpclient_test.go b/pkg/callbacks/httpclient/httpclient_test.go index 5895f289..ed14c8ac 100644 --- a/pkg/callbacks/httpclient/httpclient_test.go +++ b/pkg/callbacks/httpclient/httpclient_test.go @@ -11,6 +11,8 @@ import ( "github.com/pquerna/ffjson/ffjson" "github.com/tarmac-project/tarmac" + "github.com/tarmac-project/tarmac/proto" + pb "google.golang.org/protobuf/proto" ) type HTTPClientCase struct { @@ -20,6 +22,7 @@ type HTTPClientCase struct { name string call string json string + proto *proto.HTTPClient } func Test(t *testing.T) { @@ -67,6 +70,12 @@ func Test(t *testing.T) { name: "Simple GET", call: "Call", json: fmt.Sprintf(`{"method":"GET","headers":{"teapot": "true"},"insecure":true,"url":"%s"}`, ts.URL), + proto: &proto.HTTPClient{ + Method: "GET", + Headers: map[string]string{"teapot": "true"}, + Insecure: true, + Url: ts.URL, + }, }) tc = append(tc, HTTPClientCase{ @@ -76,6 +85,11 @@ func Test(t *testing.T) { name: "Simple GET without SkipVerify", call: "Call", json: fmt.Sprintf(`{"method":"GET","headers":{"teapot": "true"},"url":"%s"}`, ts.URL), + proto: &proto.HTTPClient{ + Method: "GET", + Headers: map[string]string{"teapot": "true"}, + Url: ts.URL, + }, }) tc = append(tc, HTTPClientCase{ @@ -85,6 +99,12 @@ func Test(t *testing.T) { name: "Simple HEAD", call: "Call", json: fmt.Sprintf(`{"method":"HEAD","headers":{"teapot": "true"},"insecure":true,"url":"%s"}`, ts.URL), + proto: &proto.HTTPClient{ + Method: "HEAD", + Headers: map[string]string{"teapot": "true"}, + Insecure: true, + Url: ts.URL, + }, }) tc = append(tc, HTTPClientCase{ @@ -94,6 +114,12 @@ func Test(t *testing.T) { name: "Simple DELETE", call: "Call", json: fmt.Sprintf(`{"method":"DELETE","headers":{"teapot": "true"},"insecure":true,"url":"%s"}`, ts.URL), + proto: &proto.HTTPClient{ + Method: "DELETE", + Headers: map[string]string{"teapot": "true"}, + Insecure: true, + Url: ts.URL, + }, }) tc = append(tc, HTTPClientCase{ @@ -103,6 +129,13 @@ func Test(t *testing.T) { name: "Simple POST", call: "Call", json: fmt.Sprintf(`{"method":"POST","headers":{"teapot": "true"},"insecure":true,"url":"%s","body":"UE9TVA=="}`, ts.URL), + proto: &proto.HTTPClient{ + Method: "POST", + Headers: map[string]string{"teapot": "true"}, + Insecure: true, + Url: ts.URL, + Body: []byte("POST"), + }, }) tc = append(tc, HTTPClientCase{ @@ -112,6 +145,13 @@ func Test(t *testing.T) { name: "Invalid POST", call: "Call", json: fmt.Sprintf(`{"method":"POST","headers":{"teapot": "true"},"insecure":true,"url":"%s","body":"NotValid"}`, ts.URL), + proto: &proto.HTTPClient{ + Method: "POST", + Headers: map[string]string{"teapot": "true"}, + Insecure: true, + Url: ts.URL, + Body: []byte("NotValid"), + }, }) tc = append(tc, HTTPClientCase{ @@ -121,6 +161,13 @@ func Test(t *testing.T) { name: "Simple PUT", call: "Call", json: fmt.Sprintf(`{"method":"PUT","headers":{"teapot": "true"},"insecure":true,"url":"%s","body":"UFVU"}`, ts.URL), + proto: &proto.HTTPClient{ + Method: "PUT", + Headers: map[string]string{"teapot": "true"}, + Insecure: true, + Url: ts.URL, + Body: []byte("PUT"), + }, }) tc = append(tc, HTTPClientCase{ @@ -130,6 +177,13 @@ func Test(t *testing.T) { name: "Invalid PUT", call: "Call", json: fmt.Sprintf(`{"method":"PUT","headers":{"teapot": "true"},"insecure":true,"url":"%s","body":"NotValid"}`, ts.URL), + proto: &proto.HTTPClient{ + Method: "PUT", + Headers: map[string]string{"teapot": "true"}, + Insecure: true, + Url: ts.URL, + Body: []byte("NotValid"), + }, }) tc = append(tc, HTTPClientCase{ @@ -139,6 +193,13 @@ func Test(t *testing.T) { name: "Simple PATCH", call: "Call", json: fmt.Sprintf(`{"method":"PATCH","headers":{"teapot": "true"},"insecure":true,"url":"%s","body":"UEFUQ0g="}`, ts.URL), + proto: &proto.HTTPClient{ + Method: "PATCH", + Headers: map[string]string{"teapot": "true"}, + Insecure: true, + Url: ts.URL, + Body: []byte("PATCH"), + }, }) tc = append(tc, HTTPClientCase{ @@ -148,6 +209,13 @@ func Test(t *testing.T) { name: "Simple PATCH", call: "Call", json: fmt.Sprintf(`{"method":"PATCH","headers":{"teapot": "true"},"insecure":true,"url":"%s","body":"NotValid"}`, ts.URL), + proto: &proto.HTTPClient{ + Method: "PATCH", + Headers: map[string]string{"teapot": "true"}, + Insecure: true, + Url: ts.URL, + Body: []byte("NotValid"), + }, }) // Loop through test cases executing and validating @@ -155,55 +223,108 @@ func Test(t *testing.T) { switch c.call { case "Call": t.Run(c.name+" Call", func(t *testing.T) { - // Call http callback - b, err := h.Call([]byte(c.json)) - if err != nil && !c.err { - t.Fatalf(" Callback failed unexpectedly - %s", err) - } - if err == nil && c.err { - t.Fatalf(" Callback unexpectedly passed") - } - - // Validate Response - var rsp tarmac.HTTPClientResponse - err = ffjson.Unmarshal(b, &rsp) - if err != nil { - t.Fatalf(" Callback Set replied with an invalid JSON - %s", err) - } - - // Tarmac Response - if rsp.Status.Code == 200 && !c.pass { - t.Fatalf(" Callback Set returned an unexpected success - %+v", rsp) - } - if rsp.Status.Code != 200 && c.pass { - t.Fatalf(" Callback Set returned an unexpected failure - %+v", rsp) - } - - // HTTP Response - if rsp.Code != c.httpCode { - t.Fatalf(" returned an unexpected response code - %+v", rsp) - return - } - - // Validate Response Header - v, ok := rsp.Headers["server"] - if (!ok || v != "tarmac") && rsp.Code == 200 { - t.Errorf(" returned an unexpected header - %+v", rsp) - } - - // Validate Payload - if len(rsp.Body) > 0 { - body, err := base64.StdEncoding.DecodeString(rsp.Body) + t.Run("JSON", func(t *testing.T) { + // Call http callback + b, err := h.Call([]byte(c.json)) + if err != nil && !c.err { + t.Fatalf(" Callback failed unexpectedly - %s", err) + } + if err == nil && c.err { + t.Fatalf(" Callback unexpectedly passed") + } + + // Validate Response + var rsp tarmac.HTTPClientResponse + err = ffjson.Unmarshal(b, &rsp) if err != nil { - t.Fatalf("Error decoding returned body - %s", err) + t.Fatalf(" Callback Set replied with an invalid JSON - %s", err) + } + + // Tarmac Response + if rsp.Status.Code == 200 && !c.pass { + t.Fatalf(" Callback Set returned an unexpected success - %+v", rsp) + } + if rsp.Status.Code != 200 && c.pass { + t.Fatalf(" Callback Set returned an unexpected failure - %+v", rsp) } - switch string(body) { - case "PUT", "POST", "PATCH": + + // HTTP Response + if rsp.Code != c.httpCode { + t.Fatalf(" returned an unexpected response code - %+v", rsp) return - default: - t.Errorf(" returned unexpected payload - %s", body) } - } + + // Validate Response Header + v, ok := rsp.Headers["server"] + if (!ok || v != "tarmac") && rsp.Code == 200 { + t.Errorf(" returned an unexpected header - %+v", rsp) + } + + // Validate Payload + if len(rsp.Body) > 0 { + body, err := base64.StdEncoding.DecodeString(rsp.Body) + if err != nil { + t.Fatalf("Error decoding returned body - %s", err) + } + switch string(body) { + case "PUT", "POST", "PATCH": + return + default: + t.Errorf(" returned unexpected payload - %s", body) + } + } + }) + t.Run("Protobuf", func(t *testing.T) { + // Generate Protobuf + msg, err := pb.Marshal(c.proto) + if err != nil { + t.Fatalf("Unable to marshal protobuf - %s", err) + } + + // Call http callback + b, err := h.Call(msg) + if err != nil && !c.err { + t.Fatalf(" Callback failed unexpectedly - %s", err) + } + + // Validate protobuf response + var rsp proto.HTTPClientResponse + err = pb.Unmarshal(b, &rsp) + if err != nil { + t.Fatalf(" Callback Set replied with an invalid Protobuf - %s", err) + } + + // Tarmac Response + if rsp.Status.Code == 200 && !c.pass { + t.Fatalf(" Callback Set returned an unexpected success - %+v", rsp) + } + + if rsp.Status.Code != 200 && c.pass { + t.Fatalf(" Callback Set returned an unexpected failure - %+v", rsp) + } + + // HTTP Response + if rsp.Code != int32(c.httpCode) { + t.Fatalf(" returned an unexpected response code - %+v", rsp) + return + } + + // Validate Response Header + v, ok := rsp.Headers["server"] + if (!ok || v != "tarmac") && rsp.Code == 200 { + t.Errorf(" returned an unexpected header - %+v", rsp) + } + + // Validate Payload + if len(rsp.Body) > 0 { + switch string(rsp.Body) { + case "PUT", "POST", "PATCH": + return + default: + t.Errorf(" returned unexpected payload - %s", rsp.Body) + } + } + }) }) } } diff --git a/pkg/callbacks/sql/sql.go b/pkg/callbacks/sql/sql.go index 903675d6..75b308d0 100644 --- a/pkg/callbacks/sql/sql.go +++ b/pkg/callbacks/sql/sql.go @@ -24,6 +24,9 @@ import ( "github.com/pquerna/ffjson/ffjson" "github.com/tarmac-project/tarmac" + + "github.com/tarmac-project/tarmac/proto" + pb "google.golang.org/protobuf/proto" ) // Database provides access to Host Callbacks that interface with a SQL database within Tarmac. The callbacks @@ -57,6 +60,109 @@ func New(cfg Config) (*Database, error) { // of data are all handled via this function. Note, this function expects the SQLQueryJSON type as input // and will return a SQLQueryResponse JSON. func (db *Database) Query(b []byte) ([]byte, error) { + msg := &proto.SQLQuery{} + err := pb.Unmarshal(b, msg) + if err != nil { + // Fallback to JSON if proto fails + return db.queryJSON(b) + } + + r := proto.SQLQueryResponse{} + r.Status = &proto.Status{Code: 200, Status: "OK"} + + if len(msg.Query) < 1 { + r.Status.Code = 400 + r.Status.Status = "SQL Query must be defined" + } + + if r.Status.Code == 200 { + rows, err := db.db.Query(msg.Query) + if err != nil { + r.Status.Code = 500 + r.Status.Status = fmt.Sprintf("Unable to execute query - %s", err) + } + defer rows.Close() + + if r.Status.Code == 200 { + + // Set last insert ID + lastID, err := rows.LastInsertId() + if err != nil { + r.Status.Code = 500 + r.Status.Status = fmt.Sprintf("Unable to get last insert ID - %s", err) + } + + if r.Status.Code == 200 { + r.LastInsertID = lastID + } + + // Set number of rows affected + rowsAffected, err := rows.RowsAffected() + if err != nil { + r.Status.Code = 500 + r.Status.Status = fmt.Sprintf("Unable to get rows affected - %s", err) + } + + if r.Status.Code == 200 { + r.RowsAffected = rowsAffected + } + + // Grab Colummns + columns, err := rows.Columns() + if err != nil { + r.Status.Code = 500 + r.Status.Status = fmt.Sprintf("Unable to process query results - %s", err) + } + r.Columns = columns + + // Loop through results + if len(columns) > 0 { + pbRows := []*proto.Row{} + for rows.Next() { + pbRow := proto.Row{} + data := make(map[string][]byte) + rawdata := make([]*sql.RawBytes, len(columns)) + for i := range columns { + rawdata[i] = new(sql.RawBytes) + } + + err := rows.Scan(rawdata...) + if err != nil { + r.Status.Code = 500 + r.Status.Status = fmt.Sprintf("Unable to process query results - %s", err) + } + + for i, raw := range rawdata { + if raw != nil { + data[columns[i]] = *raw + } + } + + if r.Status.Code == 200 { + pbRow.Data = data + pbRows = append(pbRows, &pbRow) + } + } + r.Rows = pbRows + } + } + + // Marshal a resposne + rsp, err := pb.Marshal(&r) + if err != nil { + return []byte(""), fmt.Errorf("unable to marshal database:query response") + } + + // Return response to caller + if r.Status.Code == 200 { + return rsp, nil + } + return rsp, fmt.Errorf("%s", r.Status.Status) + } +} + +// queryJSON retains the JSON interface for backwards compatibility with the Tarmac Host Callback interface. +func (db *Database) queryJSON(b []byte) ([]byte, error) { // Start Response Message assuming everything is good r := tarmac.SQLQueryResponse{} r.Status.Code = 200 diff --git a/pkg/callbacks/sql/sql_test.go b/pkg/callbacks/sql/sql_test.go index 12a5feb6..e8558d40 100644 --- a/pkg/callbacks/sql/sql_test.go +++ b/pkg/callbacks/sql/sql_test.go @@ -11,6 +11,9 @@ import ( _ "github.com/go-sql-driver/mysql" "github.com/pquerna/ffjson/ffjson" "github.com/tarmac-project/tarmac" + + "github.com/tarmac-project/tarmac/proto" + pb "google.golang.org/protobuf/proto" ) type TestCase struct { @@ -62,155 +65,320 @@ func TestSQLQuery(t *testing.T) { q: `1234e213423ewqw`, }) - t.Run("Unhappy Path", func(t *testing.T) { - for _, c := range tc { - t.Run(c.name, func(t *testing.T) { - r, err := db.Query([]byte(fmt.Sprintf(`{"query":"%s"}`, base64.StdEncoding.EncodeToString([]byte(c.q))))) - if err == nil { - t.Fatalf("Unexepected success with failure test case") + t.Run("Protobuf Based Queries", func(t *testing.T) { + + t.Run("Unhappy Path", func(t *testing.T) { + for _, c := range tc { + t.Run(c.name, func(t *testing.T) { + query := &proto.SQLQuery{Query: []byte(c.q)} + qMsg, err := pb.Marshal(query) + if err != nil { + t.Fatalf("Unable to marshal query message") + } + + r, err := db.Query(qMsg) + if err == nil { + t.Fatalf("Unexepected success with failure test case") + } + + // Unmarshal the Tarmac Response + var rsp proto.SQLQueryResponse + err = pb.Unmarshal(r, &rsp) + if err != nil { + t.Fatalf("Error parsing returned query response") + } + + // Check Status Codes + if rsp.Status.Code == 200 { + t.Fatalf("Unexpected Success with unhappy path test - %v", rsp) + } + }) + } + }) + + t.Run("Happy Path", func(t *testing.T) { + t.Run("Create Table", func(t *testing.T) { + query := &proto.SQLQuery{Query: []byte(`CREATE TABLE IF NOT EXISTS testpkg ( id int NOT NULL, name varchar(255), PRIMARY KEY (id) );`)} + qMsg, err := pb.Marshal(query) + if err != nil { + t.Fatalf("Unable to marshal query message") + } + + r, err := db.Query(qMsg) + if err != nil { + t.Fatalf("Unable to execute table creation query - %s", err) } // Unmarshal the Tarmac Response - var rsp tarmac.SQLQueryResponse - err = ffjson.Unmarshal(r, &rsp) + var rsp proto.SQLQueryResponse + err = pb.Unmarshal(r, &rsp) if err != nil { t.Fatalf("Error parsing returned query response") } // Check Status Codes - if rsp.Status.Code == 200 { - t.Fatalf("Unexpected Success with unhappy path test - %v", rsp) + if rsp.Status.Code != 200 { + t.Fatalf("Callback execution did not work, returned %d - %s", rsp.Status.Code, rsp.Status.Status) } - t.Logf("Returned Status %d - %s", rsp.Status.Code, rsp.Status.Status) }) - } - }) - t.Run("Bad JSON", func(t *testing.T) { - _, err := db.Query([]byte(`{asdfas`)) - if err == nil { - t.Fatalf("Unexpected success with bad input") - } - }) + t.Run("Insert Data", func(t *testing.T) { + query := &proto.SQLQuery{Query: []byte(`INSERT INTO testpkg (id, name) VALUES (1, "John Smith");`)} + qMsg, err := pb.Marshal(query) + if err != nil { + t.Fatalf("Unable to marshal query message") + } - t.Run("Bad Base64", func(t *testing.T) { - _, err := db.Query([]byte(`{"query": "my bologna has a first name it's this is not base64...."}`)) - if err == nil { - t.Fatalf("Unexpected success with bad input") - } - }) + r, err := db.Query(qMsg) + if err != nil { + t.Errorf("Unable to execute table creation query - %s", err) + } - t.Run("Happy Path", func(t *testing.T) { - t.Run("Create Table", func(t *testing.T) { - q := base64.StdEncoding.EncodeToString([]byte(`CREATE TABLE IF NOT EXISTS testpkg ( id int NOT NULL, name varchar(255), PRIMARY KEY (id) );`)) - j := fmt.Sprintf(`{"query":"%s"}`, q) - r, err := db.Query([]byte(j)) - if err != nil { - t.Fatalf("Unable to execute table creation query - %s", err) - } + // Unmarshal the Tarmac Response + var rsp proto.SQLQueryResponse + err = pb.Unmarshal(r, &rsp) + if err != nil { + t.Fatalf("Error parsing returned query response") + } - // Unmarshal the Tarmac Response - var rsp tarmac.SQLQueryResponse - err = ffjson.Unmarshal(r, &rsp) - if err != nil { - t.Fatalf("Error parsing returned query response") - } + // Check Status Codes + if rsp.Status.Code != 200 { + t.Fatalf("Callback execution did not work, returned %d - %s", rsp.Status.Code, rsp.Status.Status) + } + + // Check Rows Affected + if rsp.RowsAffected != 1 { + t.Fatalf("Unexpected rows affected - %d", rsp.RowsAffected) + } + + // Check Last Insert ID + if rsp.LastInsertId != 1 { + t.Fatalf("Unexpected last insert ID - %d", rsp.LastInsertId) + } + + }) + + t.Run("Select Data", func(t *testing.T) { + query := &proto.SQLQuery{Query: []byte(`SELECT * from testpkg;`)} + qMsg, err := pb.Marshal(query) + if err != nil { + t.Fatalf("Unable to marshal query message") + } + + r, err := db.Query(qMsg) + if err != nil { + t.Errorf("Unable to execute table creation query - %s", err) + } + + // Unmarshal the Tarmac Response + var rsp proto.SQLQueryResponse + err = pb.Unmarshal(r, &rsp) + if err != nil { + t.Fatalf("Error parsing returned query response") + } + + // Check Status Codes + if rsp.Status.Code != 200 { + t.Fatalf("Callback execution did not work, returned %d - %s", rsp.Status.Code, rsp.Status.Status) + } + + // Verify Columns + if len(rsp.Columns) != 1 { + t.Fatalf("Unexpected number of columns returned - %d", len(rsp.Columns)) + } + + // Verify Rows + if len(rsp.Rows) != 1 { + t.Fatalf("Unexpected number of rows returned - %d", len(rsp.Rows)) + } + + // Verify Data + if string(rsp.Rows[0].Data["id"]) != "1" && string(rsp.Rows[0].Data["name"]) != "John Smith" { + t.Fatalf("Unexpected data returned - %v", rsp.Rows[0].Data) + } + + }) + + t.Run("Delete Table", func(t *testing.T) { + query := &proto.SQLQuery{Query: []byte(`DROP TABLE IF EXISTS testpkg;`)} + qMsg, err := pb.Marshal(query) + if err != nil { + t.Fatalf("Unable to marshal query message") + } + + r, err := db.Query(qMsg) + if err != nil { + t.Errorf("Unable to execute table creation query - %s", err) + } + + // Unmarshal the Tarmac Response + var rsp proto.SQLQueryResponse + err = pb.Unmarshal(r, &rsp) + if err != nil { + t.Fatalf("Error parsing returned query response") + } + + // Check Status Codes + if rsp.Status.Code != 200 { + t.Fatalf("Callback execution did not work, returned %d - %s", rsp.Status.Code, rsp.Status.Status) + } + }) - // Check Status Codes - if rsp.Status.Code != 200 { - t.Fatalf("Callback execution did not work, returned %d - %s", rsp.Status.Code, rsp.Status.Status) - } }) + }) - t.Run("Insert Data", func(t *testing.T) { - q := base64.StdEncoding.EncodeToString([]byte(`INSERT INTO testpkg (id, name) VALUES (1, "John Smith");`)) - j := fmt.Sprintf(`{"query":"%s"}`, q) - r, err := db.Query([]byte(j)) - if err != nil { - t.Errorf("Unable to execute table creation query - %s", err) + // Test the JSON Interface for Backwards Compatibility + t.Run("JSON Based Queries", func(t *testing.T) { + + t.Run("Unhappy Path", func(t *testing.T) { + for _, c := range tc { + t.Run(c.name, func(t *testing.T) { + r, err := db.Query([]byte(fmt.Sprintf(`{"query":"%s"}`, base64.StdEncoding.EncodeToString([]byte(c.q))))) + if err == nil { + t.Fatalf("Unexepected success with failure test case") + } + + // Unmarshal the Tarmac Response + var rsp tarmac.SQLQueryResponse + err = ffjson.Unmarshal(r, &rsp) + if err != nil { + t.Fatalf("Error parsing returned query response") + } + + // Check Status Codes + if rsp.Status.Code == 200 { + t.Fatalf("Unexpected Success with unhappy path test - %v", rsp) + } + }) } + }) - // Unmarshal the Tarmac Response - var rsp tarmac.SQLQueryResponse - err = ffjson.Unmarshal(r, &rsp) - if err != nil { - t.Fatalf("Error parsing returned query response") + t.Run("Bad JSON", func(t *testing.T) { + _, err := db.Query([]byte(`{asdfas`)) + if err == nil { + t.Fatalf("Unexpected success with bad input") } + }) - // Check Status Codes - if rsp.Status.Code != 200 { - t.Fatalf("Callback execution did not work, returned %d - %s", rsp.Status.Code, rsp.Status.Status) + t.Run("Bad Base64", func(t *testing.T) { + _, err := db.Query([]byte(`{"query": "my bologna has a first name it's this is not base64...."}`)) + if err == nil { + t.Fatalf("Unexpected success with bad input") } }) - t.Run("Select Data", func(t *testing.T) { - q := base64.StdEncoding.EncodeToString([]byte(`SELECT * from testpkg;`)) - j := fmt.Sprintf(`{"query":"%s"}`, q) - r, err := db.Query([]byte(j)) - if err != nil { - t.Errorf("Unable to execute table creation query - %s", err) - } + t.Run("Happy Path", func(t *testing.T) { + t.Run("Create Table", func(t *testing.T) { + q := base64.StdEncoding.EncodeToString([]byte(`CREATE TABLE IF NOT EXISTS testpkg ( id int NOT NULL, name varchar(255), PRIMARY KEY (id) );`)) + j := fmt.Sprintf(`{"query":"%s"}`, q) + r, err := db.Query([]byte(j)) + if err != nil { + t.Fatalf("Unable to execute table creation query - %s", err) + } - // Unmarshal the Tarmac Response - var rsp tarmac.SQLQueryResponse - err = ffjson.Unmarshal(r, &rsp) - if err != nil { - t.Fatalf("Error parsing returned query response") - } + // Unmarshal the Tarmac Response + var rsp tarmac.SQLQueryResponse + err = ffjson.Unmarshal(r, &rsp) + if err != nil { + t.Fatalf("Error parsing returned query response") + } - // Check Status Codes - if rsp.Status.Code != 200 { - t.Fatalf("Callback execution did not work, returned %d - %s", rsp.Status.Code, rsp.Status.Status) - } + // Check Status Codes + if rsp.Status.Code != 200 { + t.Fatalf("Callback execution did not work, returned %d - %s", rsp.Status.Code, rsp.Status.Status) + } + }) - // Verify query response - data, err := base64.StdEncoding.DecodeString(rsp.Data) - if err != nil { - t.Fatalf("Callback returned undecodable response - %s", err) - } + t.Run("Insert Data", func(t *testing.T) { + q := base64.StdEncoding.EncodeToString([]byte(`INSERT INTO testpkg (id, name) VALUES (1, "John Smith");`)) + j := fmt.Sprintf(`{"query":"%s"}`, q) + r, err := db.Query([]byte(j)) + if err != nil { + t.Errorf("Unable to execute table creation query - %s", err) + } - // Parse returned SQL Data - type rowData struct { - ID []byte `json:"id"` - Name []byte `json:"name"` - } + // Unmarshal the Tarmac Response + var rsp tarmac.SQLQueryResponse + err = ffjson.Unmarshal(r, &rsp) + if err != nil { + t.Fatalf("Error parsing returned query response") + } - var records []rowData - err = ffjson.Unmarshal(data, &records) - if err != nil { - t.Fatalf("Unable to unmarshal SQL response - %s", err) - } + // Check Status Codes + if rsp.Status.Code != 200 { + t.Fatalf("Callback execution did not work, returned %d - %s", rsp.Status.Code, rsp.Status.Status) + } + }) - id, err := strconv.Atoi(string(records[0].ID)) - if err != nil { - t.Fatalf("Unable to convert ID to integer - %s", err) - } + t.Run("Select Data", func(t *testing.T) { + q := base64.StdEncoding.EncodeToString([]byte(`SELECT * from testpkg;`)) + j := fmt.Sprintf(`{"query":"%s"}`, q) + r, err := db.Query([]byte(j)) + if err != nil { + t.Errorf("Unable to execute table creation query - %s", err) + } - if id != 1 { - t.Fatalf("Unexpected value from Database got %d", id) - } + // Unmarshal the Tarmac Response + var rsp tarmac.SQLQueryResponse + err = ffjson.Unmarshal(r, &rsp) + if err != nil { + t.Fatalf("Error parsing returned query response") + } - }) + // Check Status Codes + if rsp.Status.Code != 200 { + t.Fatalf("Callback execution did not work, returned %d - %s", rsp.Status.Code, rsp.Status.Status) + } - t.Run("Delete Table", func(t *testing.T) { - q := base64.StdEncoding.EncodeToString([]byte(`DROP TABLE IF EXISTS testpkg;`)) - j := fmt.Sprintf(`{"query":"%s"}`, q) - r, err := db.Query([]byte(j)) - if err != nil { - t.Errorf("Unable to execute table creation query - %s", err) - } + // Verify query response + data, err := base64.StdEncoding.DecodeString(rsp.Data) + if err != nil { + t.Fatalf("Callback returned undecodable response - %s", err) + } - // Unmarshal the Tarmac Response - var rsp tarmac.SQLQueryResponse - err = ffjson.Unmarshal(r, &rsp) - if err != nil { - t.Fatalf("Error parsing returned query response") - } + // Parse returned SQL Data + type rowData struct { + ID []byte `json:"id"` + Name []byte `json:"name"` + } - // Check Status Codes - if rsp.Status.Code != 200 { - t.Fatalf("Callback execution did not work, returned %d - %s", rsp.Status.Code, rsp.Status.Status) - } + var records []rowData + err = ffjson.Unmarshal(data, &records) + if err != nil { + t.Fatalf("Unable to unmarshal SQL response - %s", err) + } + + id, err := strconv.Atoi(string(records[0].ID)) + if err != nil { + t.Fatalf("Unable to convert ID to integer - %s", err) + } + + if id != 1 { + t.Fatalf("Unexpected value from Database got %d", id) + } + + }) + + t.Run("Delete Table", func(t *testing.T) { + q := base64.StdEncoding.EncodeToString([]byte(`DROP TABLE IF EXISTS testpkg;`)) + j := fmt.Sprintf(`{"query":"%s"}`, q) + r, err := db.Query([]byte(j)) + if err != nil { + t.Errorf("Unable to execute table creation query - %s", err) + } + + // Unmarshal the Tarmac Response + var rsp tarmac.SQLQueryResponse + err = ffjson.Unmarshal(r, &rsp) + if err != nil { + t.Fatalf("Error parsing returned query response") + } + + // Check Status Codes + if rsp.Status.Code != 200 { + t.Fatalf("Callback execution did not work, returned %d - %s", rsp.Status.Code, rsp.Status.Status) + } + }) }) }) } From dcc79e1e13c100f47b30c69a0cda207aadca0a8c Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 4 Aug 2024 07:31:52 -0700 Subject: [PATCH 02/31] Adding Proto directory --- proto/http.pb.go | 312 +++++ proto/http_vtproto.pb.go | 1681 ++++++++++++++++++++++++ proto/kvstore.pb.go | 607 +++++++++ proto/kvstore_vtproto.pb.go | 2451 +++++++++++++++++++++++++++++++++++ proto/metrics.pb.go | 301 +++++ proto/metrics_vtproto.pb.go | 1056 +++++++++++++++ proto/sql.pb.go | 340 +++++ proto/sql_vtproto.pb.go | 1509 +++++++++++++++++++++ proto/tarmac.pb.go | 164 +++ proto/tarmac_vtproto.pb.go | 378 ++++++ 10 files changed, 8799 insertions(+) create mode 100644 proto/http.pb.go create mode 100644 proto/http_vtproto.pb.go create mode 100644 proto/kvstore.pb.go create mode 100644 proto/kvstore_vtproto.pb.go create mode 100644 proto/metrics.pb.go create mode 100644 proto/metrics_vtproto.pb.go create mode 100644 proto/sql.pb.go create mode 100644 proto/sql_vtproto.pb.go create mode 100644 proto/tarmac.pb.go create mode 100644 proto/tarmac_vtproto.pb.go diff --git a/proto/http.pb.go b/proto/http.pb.go new file mode 100644 index 00000000..6cfdd0ff --- /dev/null +++ b/proto/http.pb.go @@ -0,0 +1,312 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v5.27.1 +// source: http.proto + +package proto + +import ( + reflect "reflect" + sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// HTTPClient is a structure used to create HTTP calls to remote systems. +type HTTPClient struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Method is the HTTP method type for the HTTP request; valid options are + // GET, POST, PUT, PATCH, HEAD, & DELETE. + Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` + // Headers are the HTTP headers to include in the HTTP request. + Headers map[string]string `protobuf:"bytes,2,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // URL is the HTTP URL to call. + Url string `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"` + // Body is the user-supplied HTTP body data. This field should contain the + // request payload data. + Body []byte `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"` + // Insecure will disable TLS host verification; this is common with + // self-signed certificates; however, use caution. + Insecure bool `protobuf:"varint,5,opt,name=insecure,proto3" json:"insecure,omitempty"` +} + +func (x *HTTPClient) Reset() { + *x = HTTPClient{} + if protoimpl.UnsafeEnabled { + mi := &file_http_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HTTPClient) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HTTPClient) ProtoMessage() {} + +func (x *HTTPClient) ProtoReflect() protoreflect.Message { + mi := &file_http_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HTTPClient.ProtoReflect.Descriptor instead. +func (*HTTPClient) Descriptor() ([]byte, []int) { + return file_http_proto_rawDescGZIP(), []int{0} +} + +func (x *HTTPClient) GetMethod() string { + if x != nil { + return x.Method + } + return "" +} + +func (x *HTTPClient) GetHeaders() map[string]string { + if x != nil { + return x.Headers + } + return nil +} + +func (x *HTTPClient) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +func (x *HTTPClient) GetBody() []byte { + if x != nil { + return x.Body + } + return nil +} + +func (x *HTTPClient) GetInsecure() bool { + if x != nil { + return x.Insecure + } + return false +} + +// HTTPClientResponse is a structure supplied as a response message to a remote +// HTTP call callback function. +type HTTPClientResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Status is the human readable error message or success message for function + // execution. + Status *Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` + // Code is the HTTP Status Code returned from the target server. + Code int32 `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"` + // Headers are the HTTP headers returned from the HTTP request. + Headers map[string]string `protobuf:"bytes,3,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // Body is the server-supplied HTTP payload data. The server-supplied payload + // will be a byte slice. + Body []byte `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"` +} + +func (x *HTTPClientResponse) Reset() { + *x = HTTPClientResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_http_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HTTPClientResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HTTPClientResponse) ProtoMessage() {} + +func (x *HTTPClientResponse) ProtoReflect() protoreflect.Message { + mi := &file_http_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HTTPClientResponse.ProtoReflect.Descriptor instead. +func (*HTTPClientResponse) Descriptor() ([]byte, []int) { + return file_http_proto_rawDescGZIP(), []int{1} +} + +func (x *HTTPClientResponse) GetStatus() *Status { + if x != nil { + return x.Status + } + return nil +} + +func (x *HTTPClientResponse) GetCode() int32 { + if x != nil { + return x.Code + } + return 0 +} + +func (x *HTTPClientResponse) GetHeaders() map[string]string { + if x != nil { + return x.Headers + } + return nil +} + +func (x *HTTPClientResponse) GetBody() []byte { + if x != nil { + return x.Body + } + return nil +} + +var File_http_proto protoreflect.FileDescriptor + +var file_http_proto_rawDesc = []byte{ + 0x0a, 0x0a, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x74, 0x61, + 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x1a, 0x0c, 0x74, 0x61, 0x72, 0x6d, 0x61, + 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe2, 0x01, 0x0a, 0x0a, 0x48, 0x54, 0x54, 0x50, + 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x3e, + 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x24, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x48, 0x54, + 0x54, 0x50, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x10, + 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, + 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, + 0x62, 0x6f, 0x64, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, + 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xe8, 0x01, 0x0a, + 0x12, 0x48, 0x54, 0x54, 0x50, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x63, + 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, + 0x46, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x2c, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x48, + 0x54, 0x54, 0x50, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, + 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2d, 0x70, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_http_proto_rawDescOnce sync.Once + file_http_proto_rawDescData = file_http_proto_rawDesc +) + +func file_http_proto_rawDescGZIP() []byte { + file_http_proto_rawDescOnce.Do(func() { + file_http_proto_rawDescData = protoimpl.X.CompressGZIP(file_http_proto_rawDescData) + }) + return file_http_proto_rawDescData +} + +var file_http_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_http_proto_goTypes = []interface{}{ + (*HTTPClient)(nil), // 0: tarmac.http.HTTPClient + (*HTTPClientResponse)(nil), // 1: tarmac.http.HTTPClientResponse + nil, // 2: tarmac.http.HTTPClient.HeadersEntry + nil, // 3: tarmac.http.HTTPClientResponse.HeadersEntry + (*Status)(nil), // 4: tarmac.Status +} +var file_http_proto_depIdxs = []int32{ + 2, // 0: tarmac.http.HTTPClient.headers:type_name -> tarmac.http.HTTPClient.HeadersEntry + 4, // 1: tarmac.http.HTTPClientResponse.status:type_name -> tarmac.Status + 3, // 2: tarmac.http.HTTPClientResponse.headers:type_name -> tarmac.http.HTTPClientResponse.HeadersEntry + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_http_proto_init() } +func file_http_proto_init() { + if File_http_proto != nil { + return + } + file_tarmac_proto_init() + if !protoimpl.UnsafeEnabled { + file_http_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HTTPClient); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_http_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HTTPClientResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_http_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_http_proto_goTypes, + DependencyIndexes: file_http_proto_depIdxs, + MessageInfos: file_http_proto_msgTypes, + }.Build() + File_http_proto = out.File + file_http_proto_rawDesc = nil + file_http_proto_goTypes = nil + file_http_proto_depIdxs = nil +} diff --git a/proto/http_vtproto.pb.go b/proto/http_vtproto.pb.go new file mode 100644 index 00000000..881f9b68 --- /dev/null +++ b/proto/http_vtproto.pb.go @@ -0,0 +1,1681 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.6.0 +// source: http.proto + +package proto + +import ( + fmt "fmt" + io "io" + unsafe "unsafe" + + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *HTTPClient) CloneVT() *HTTPClient { + if m == nil { + return (*HTTPClient)(nil) + } + r := new(HTTPClient) + r.Method = m.Method + r.Url = m.Url + r.Insecure = m.Insecure + if rhs := m.Headers; rhs != nil { + tmpContainer := make(map[string]string, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v + } + r.Headers = tmpContainer + } + if rhs := m.Body; rhs != nil { + tmpBytes := make([]byte, len(rhs)) + copy(tmpBytes, rhs) + r.Body = tmpBytes + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *HTTPClient) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *HTTPClientResponse) CloneVT() *HTTPClientResponse { + if m == nil { + return (*HTTPClientResponse)(nil) + } + r := new(HTTPClientResponse) + r.Status = m.Status.CloneVT() + r.Code = m.Code + if rhs := m.Headers; rhs != nil { + tmpContainer := make(map[string]string, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v + } + r.Headers = tmpContainer + } + if rhs := m.Body; rhs != nil { + tmpBytes := make([]byte, len(rhs)) + copy(tmpBytes, rhs) + r.Body = tmpBytes + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *HTTPClientResponse) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (this *HTTPClient) EqualVT(that *HTTPClient) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Method != that.Method { + return false + } + if len(this.Headers) != len(that.Headers) { + return false + } + for i, vx := range this.Headers { + vy, ok := that.Headers[i] + if !ok { + return false + } + if vx != vy { + return false + } + } + if this.Url != that.Url { + return false + } + if string(this.Body) != string(that.Body) { + return false + } + if this.Insecure != that.Insecure { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *HTTPClient) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*HTTPClient) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *HTTPClientResponse) EqualVT(that *HTTPClientResponse) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Status.EqualVT(that.Status) { + return false + } + if this.Code != that.Code { + return false + } + if len(this.Headers) != len(that.Headers) { + return false + } + for i, vx := range this.Headers { + vy, ok := that.Headers[i] + if !ok { + return false + } + if vx != vy { + return false + } + } + if string(this.Body) != string(that.Body) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *HTTPClientResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*HTTPClientResponse) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *HTTPClient) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *HTTPClient) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *HTTPClient) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Insecure { + i-- + if m.Insecure { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + if len(m.Body) > 0 { + i -= len(m.Body) + copy(dAtA[i:], m.Body) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Body))) + i-- + dAtA[i] = 0x22 + } + if len(m.Url) > 0 { + i -= len(m.Url) + copy(dAtA[i:], m.Url) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Url))) + i-- + dAtA[i] = 0x1a + } + if len(m.Headers) > 0 { + for k := range m.Headers { + v := m.Headers[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Method) > 0 { + i -= len(m.Method) + copy(dAtA[i:], m.Method) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Method))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *HTTPClientResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *HTTPClientResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *HTTPClientResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Body) > 0 { + i -= len(m.Body) + copy(dAtA[i:], m.Body) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Body))) + i-- + dAtA[i] = 0x22 + } + if len(m.Headers) > 0 { + for k := range m.Headers { + v := m.Headers[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x1a + } + } + if m.Code != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Code)) + i-- + dAtA[i] = 0x10 + } + if m.Status != nil { + size, err := m.Status.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *HTTPClient) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *HTTPClient) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *HTTPClient) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Insecure { + i-- + if m.Insecure { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + if len(m.Body) > 0 { + i -= len(m.Body) + copy(dAtA[i:], m.Body) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Body))) + i-- + dAtA[i] = 0x22 + } + if len(m.Url) > 0 { + i -= len(m.Url) + copy(dAtA[i:], m.Url) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Url))) + i-- + dAtA[i] = 0x1a + } + if len(m.Headers) > 0 { + for k := range m.Headers { + v := m.Headers[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Method) > 0 { + i -= len(m.Method) + copy(dAtA[i:], m.Method) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Method))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *HTTPClientResponse) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *HTTPClientResponse) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *HTTPClientResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Body) > 0 { + i -= len(m.Body) + copy(dAtA[i:], m.Body) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Body))) + i-- + dAtA[i] = 0x22 + } + if len(m.Headers) > 0 { + for k := range m.Headers { + v := m.Headers[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x1a + } + } + if m.Code != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Code)) + i-- + dAtA[i] = 0x10 + } + if m.Status != nil { + size, err := m.Status.MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *HTTPClient) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Method) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.Headers) > 0 { + for k, v := range m.Headers { + _ = k + _ = v + mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + 1 + len(v) + protohelpers.SizeOfVarint(uint64(len(v))) + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } + l = len(m.Url) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Body) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Insecure { + n += 2 + } + n += len(m.unknownFields) + return n +} + +func (m *HTTPClientResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != nil { + l = m.Status.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Code != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Code)) + } + if len(m.Headers) > 0 { + for k, v := range m.Headers { + _ = k + _ = v + mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + 1 + len(v) + protohelpers.SizeOfVarint(uint64(len(v))) + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } + l = len(m.Body) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *HTTPClient) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: HTTPClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HTTPClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Method", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Method = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Headers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Headers == nil { + m.Headers = make(map[string]string) + } + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Headers[mapkey] = mapvalue + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Url", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Url = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Body = append(m.Body[:0], dAtA[iNdEx:postIndex]...) + if m.Body == nil { + m.Body = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Insecure", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Insecure = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *HTTPClientResponse) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: HTTPClientResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HTTPClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &Status{} + } + if err := m.Status.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + m.Code = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Code |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Headers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Headers == nil { + m.Headers = make(map[string]string) + } + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Headers[mapkey] = mapvalue + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Body = append(m.Body[:0], dAtA[iNdEx:postIndex]...) + if m.Body == nil { + m.Body = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *HTTPClient) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: HTTPClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HTTPClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Method", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + } + m.Method = stringValue + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Headers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Headers == nil { + m.Headers = make(map[string]string) + } + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + if intStringLenmapkey == 0 { + mapkey = "" + } else { + mapkey = unsafe.String(&dAtA[iNdEx], intStringLenmapkey) + } + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + if intStringLenmapvalue == 0 { + mapvalue = "" + } else { + mapvalue = unsafe.String(&dAtA[iNdEx], intStringLenmapvalue) + } + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Headers[mapkey] = mapvalue + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Url", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + } + m.Url = stringValue + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Body = dAtA[iNdEx:postIndex] + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Insecure", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Insecure = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *HTTPClientResponse) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: HTTPClientResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HTTPClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &Status{} + } + if err := m.Status.UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + m.Code = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Code |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Headers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Headers == nil { + m.Headers = make(map[string]string) + } + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + if intStringLenmapkey == 0 { + mapkey = "" + } else { + mapkey = unsafe.String(&dAtA[iNdEx], intStringLenmapkey) + } + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + if intStringLenmapvalue == 0 { + mapvalue = "" + } else { + mapvalue = unsafe.String(&dAtA[iNdEx], intStringLenmapvalue) + } + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Headers[mapkey] = mapvalue + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Body = dAtA[iNdEx:postIndex] + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/proto/kvstore.pb.go b/proto/kvstore.pb.go new file mode 100644 index 00000000..b2c19bea --- /dev/null +++ b/proto/kvstore.pb.go @@ -0,0 +1,607 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v5.27.1 +// source: kvstore.proto + +package proto + +import ( + reflect "reflect" + sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// KVStoreGet is a structure used to create Get request callbacks to the Tarmac +// KVStore interface. +// +// This structure is a general request type used for all KVStore types provided +// by Tarmac. +type KVStoreGet struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Key is the index key to use when accessing the key:value store. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *KVStoreGet) Reset() { + *x = KVStoreGet{} + if protoimpl.UnsafeEnabled { + mi := &file_kvstore_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *KVStoreGet) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KVStoreGet) ProtoMessage() {} + +func (x *KVStoreGet) ProtoReflect() protoreflect.Message { + mi := &file_kvstore_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use KVStoreGet.ProtoReflect.Descriptor instead. +func (*KVStoreGet) Descriptor() ([]byte, []int) { + return file_kvstore_proto_rawDescGZIP(), []int{0} +} + +func (x *KVStoreGet) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +// KVStoreGetResponse is a structure supplied as response messages to KVStore +// Get requests. +// +// This response is a general response type used for all KVStore types provided +// by Tarmac. +type KVStoreGetResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Status is the human readable error message or success message for function + // execution. + Status *Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` + // Data is the response data provided by the key:value store. + // This data is a byte slice to provide a simple field for arbitrary data. + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *KVStoreGetResponse) Reset() { + *x = KVStoreGetResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_kvstore_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *KVStoreGetResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KVStoreGetResponse) ProtoMessage() {} + +func (x *KVStoreGetResponse) ProtoReflect() protoreflect.Message { + mi := &file_kvstore_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use KVStoreGetResponse.ProtoReflect.Descriptor instead. +func (*KVStoreGetResponse) Descriptor() ([]byte, []int) { + return file_kvstore_proto_rawDescGZIP(), []int{1} +} + +func (x *KVStoreGetResponse) GetStatus() *Status { + if x != nil { + return x.Status + } + return nil +} + +func (x *KVStoreGetResponse) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +// KVStoreSet is a structure used to create a Set request callback to the +// Tarmac KVStore interface. +// +// This structure is a general request type used for all KVStore types provided +// by Tarmac. +type KVStoreSet struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Key is the index key used to store the data. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // Data is the user-supplied key:value data. + // Tarmac expects this field to be a byte slice. + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *KVStoreSet) Reset() { + *x = KVStoreSet{} + if protoimpl.UnsafeEnabled { + mi := &file_kvstore_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *KVStoreSet) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KVStoreSet) ProtoMessage() {} + +func (x *KVStoreSet) ProtoReflect() protoreflect.Message { + mi := &file_kvstore_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use KVStoreSet.ProtoReflect.Descriptor instead. +func (*KVStoreSet) Descriptor() ([]byte, []int) { + return file_kvstore_proto_rawDescGZIP(), []int{2} +} + +func (x *KVStoreSet) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *KVStoreSet) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +// KVStoreSetResponse is a structure supplied as a response message to the +// KVStore Set callback function. +// +// This response is a general response type used for all KVStore types provided +// by Tarmac. +type KVStoreSetResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Status is the human readable error message or success message for function + // execution. + Status *Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` +} + +func (x *KVStoreSetResponse) Reset() { + *x = KVStoreSetResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_kvstore_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *KVStoreSetResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KVStoreSetResponse) ProtoMessage() {} + +func (x *KVStoreSetResponse) ProtoReflect() protoreflect.Message { + mi := &file_kvstore_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use KVStoreSetResponse.ProtoReflect.Descriptor instead. +func (*KVStoreSetResponse) Descriptor() ([]byte, []int) { + return file_kvstore_proto_rawDescGZIP(), []int{3} +} + +func (x *KVStoreSetResponse) GetStatus() *Status { + if x != nil { + return x.Status + } + return nil +} + +// KVStoreDelete is a structure used to create Delete callback requests to the +// Tarmac KVStore interface. +// +// This structure is a general request type used for all KVStore types provided +// by Tarmac. +type KVStoreDelete struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Key is the index key used to store the data. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *KVStoreDelete) Reset() { + *x = KVStoreDelete{} + if protoimpl.UnsafeEnabled { + mi := &file_kvstore_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *KVStoreDelete) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KVStoreDelete) ProtoMessage() {} + +func (x *KVStoreDelete) ProtoReflect() protoreflect.Message { + mi := &file_kvstore_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use KVStoreDelete.ProtoReflect.Descriptor instead. +func (*KVStoreDelete) Descriptor() ([]byte, []int) { + return file_kvstore_proto_rawDescGZIP(), []int{4} +} + +func (x *KVStoreDelete) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +// KVStoreDeleteResponse is a structure supplied as a response message to the +// KVStore Delete callback function. +// +// This response is a general response type used for all KVStore types provided +// by Tarmac. +type KVStoreDeleteResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Status is the human readable error message or success message for function + // execution. + Status *Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` +} + +func (x *KVStoreDeleteResponse) Reset() { + *x = KVStoreDeleteResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_kvstore_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *KVStoreDeleteResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KVStoreDeleteResponse) ProtoMessage() {} + +func (x *KVStoreDeleteResponse) ProtoReflect() protoreflect.Message { + mi := &file_kvstore_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use KVStoreDeleteResponse.ProtoReflect.Descriptor instead. +func (*KVStoreDeleteResponse) Descriptor() ([]byte, []int) { + return file_kvstore_proto_rawDescGZIP(), []int{5} +} + +func (x *KVStoreDeleteResponse) GetStatus() *Status { + if x != nil { + return x.Status + } + return nil +} + +// This response is a general response type used for all KVStore types provided +// by Tarmac. +type KVStoreKeysResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Status is the human readable error message or success message for function + // execution. + Status *Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` + // Keys is a list of keys available within the KV Store. + Keys []string `protobuf:"bytes,2,rep,name=keys,proto3" json:"keys,omitempty"` +} + +func (x *KVStoreKeysResponse) Reset() { + *x = KVStoreKeysResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_kvstore_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *KVStoreKeysResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KVStoreKeysResponse) ProtoMessage() {} + +func (x *KVStoreKeysResponse) ProtoReflect() protoreflect.Message { + mi := &file_kvstore_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use KVStoreKeysResponse.ProtoReflect.Descriptor instead. +func (*KVStoreKeysResponse) Descriptor() ([]byte, []int) { + return file_kvstore_proto_rawDescGZIP(), []int{6} +} + +func (x *KVStoreKeysResponse) GetStatus() *Status { + if x != nil { + return x.Status + } + return nil +} + +func (x *KVStoreKeysResponse) GetKeys() []string { + if x != nil { + return x.Keys + } + return nil +} + +var File_kvstore_proto protoreflect.FileDescriptor + +var file_kvstore_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x6b, 0x76, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x0e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x6b, 0x76, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x1a, + 0x0c, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1e, 0x0a, + 0x0a, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x47, 0x65, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x50, 0x0a, + 0x12, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x64, + 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, + 0x32, 0x0a, 0x0a, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x53, 0x65, 0x74, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, + 0x61, 0x74, 0x61, 0x22, 0x3c, 0x0a, 0x12, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x53, 0x65, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x61, 0x72, 0x6d, + 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x22, 0x21, 0x0a, 0x0d, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x44, 0x65, 0x6c, 0x65, + 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x22, 0x3f, 0x0a, 0x15, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, + 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, + 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x51, 0x0a, 0x13, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, + 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, + 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2d, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_kvstore_proto_rawDescOnce sync.Once + file_kvstore_proto_rawDescData = file_kvstore_proto_rawDesc +) + +func file_kvstore_proto_rawDescGZIP() []byte { + file_kvstore_proto_rawDescOnce.Do(func() { + file_kvstore_proto_rawDescData = protoimpl.X.CompressGZIP(file_kvstore_proto_rawDescData) + }) + return file_kvstore_proto_rawDescData +} + +var file_kvstore_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_kvstore_proto_goTypes = []interface{}{ + (*KVStoreGet)(nil), // 0: tarmac.kvstore.KVStoreGet + (*KVStoreGetResponse)(nil), // 1: tarmac.kvstore.KVStoreGetResponse + (*KVStoreSet)(nil), // 2: tarmac.kvstore.KVStoreSet + (*KVStoreSetResponse)(nil), // 3: tarmac.kvstore.KVStoreSetResponse + (*KVStoreDelete)(nil), // 4: tarmac.kvstore.KVStoreDelete + (*KVStoreDeleteResponse)(nil), // 5: tarmac.kvstore.KVStoreDeleteResponse + (*KVStoreKeysResponse)(nil), // 6: tarmac.kvstore.KVStoreKeysResponse + (*Status)(nil), // 7: tarmac.Status +} +var file_kvstore_proto_depIdxs = []int32{ + 7, // 0: tarmac.kvstore.KVStoreGetResponse.status:type_name -> tarmac.Status + 7, // 1: tarmac.kvstore.KVStoreSetResponse.status:type_name -> tarmac.Status + 7, // 2: tarmac.kvstore.KVStoreDeleteResponse.status:type_name -> tarmac.Status + 7, // 3: tarmac.kvstore.KVStoreKeysResponse.status:type_name -> tarmac.Status + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_kvstore_proto_init() } +func file_kvstore_proto_init() { + if File_kvstore_proto != nil { + return + } + file_tarmac_proto_init() + if !protoimpl.UnsafeEnabled { + file_kvstore_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*KVStoreGet); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kvstore_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*KVStoreGetResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kvstore_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*KVStoreSet); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kvstore_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*KVStoreSetResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kvstore_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*KVStoreDelete); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kvstore_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*KVStoreDeleteResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kvstore_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*KVStoreKeysResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_kvstore_proto_rawDesc, + NumEnums: 0, + NumMessages: 7, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_kvstore_proto_goTypes, + DependencyIndexes: file_kvstore_proto_depIdxs, + MessageInfos: file_kvstore_proto_msgTypes, + }.Build() + File_kvstore_proto = out.File + file_kvstore_proto_rawDesc = nil + file_kvstore_proto_goTypes = nil + file_kvstore_proto_depIdxs = nil +} diff --git a/proto/kvstore_vtproto.pb.go b/proto/kvstore_vtproto.pb.go new file mode 100644 index 00000000..b51e2699 --- /dev/null +++ b/proto/kvstore_vtproto.pb.go @@ -0,0 +1,2451 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.6.0 +// source: kvstore.proto + +package proto + +import ( + fmt "fmt" + io "io" + unsafe "unsafe" + + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *KVStoreGet) CloneVT() *KVStoreGet { + if m == nil { + return (*KVStoreGet)(nil) + } + r := new(KVStoreGet) + r.Key = m.Key + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *KVStoreGet) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *KVStoreGetResponse) CloneVT() *KVStoreGetResponse { + if m == nil { + return (*KVStoreGetResponse)(nil) + } + r := new(KVStoreGetResponse) + r.Status = m.Status.CloneVT() + if rhs := m.Data; rhs != nil { + tmpBytes := make([]byte, len(rhs)) + copy(tmpBytes, rhs) + r.Data = tmpBytes + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *KVStoreGetResponse) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *KVStoreSet) CloneVT() *KVStoreSet { + if m == nil { + return (*KVStoreSet)(nil) + } + r := new(KVStoreSet) + r.Key = m.Key + if rhs := m.Data; rhs != nil { + tmpBytes := make([]byte, len(rhs)) + copy(tmpBytes, rhs) + r.Data = tmpBytes + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *KVStoreSet) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *KVStoreSetResponse) CloneVT() *KVStoreSetResponse { + if m == nil { + return (*KVStoreSetResponse)(nil) + } + r := new(KVStoreSetResponse) + r.Status = m.Status.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *KVStoreSetResponse) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *KVStoreDelete) CloneVT() *KVStoreDelete { + if m == nil { + return (*KVStoreDelete)(nil) + } + r := new(KVStoreDelete) + r.Key = m.Key + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *KVStoreDelete) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *KVStoreDeleteResponse) CloneVT() *KVStoreDeleteResponse { + if m == nil { + return (*KVStoreDeleteResponse)(nil) + } + r := new(KVStoreDeleteResponse) + r.Status = m.Status.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *KVStoreDeleteResponse) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *KVStoreKeysResponse) CloneVT() *KVStoreKeysResponse { + if m == nil { + return (*KVStoreKeysResponse)(nil) + } + r := new(KVStoreKeysResponse) + r.Status = m.Status.CloneVT() + if rhs := m.Keys; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.Keys = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *KVStoreKeysResponse) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (this *KVStoreGet) EqualVT(that *KVStoreGet) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Key != that.Key { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *KVStoreGet) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*KVStoreGet) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *KVStoreGetResponse) EqualVT(that *KVStoreGetResponse) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Status.EqualVT(that.Status) { + return false + } + if string(this.Data) != string(that.Data) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *KVStoreGetResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*KVStoreGetResponse) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *KVStoreSet) EqualVT(that *KVStoreSet) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Key != that.Key { + return false + } + if string(this.Data) != string(that.Data) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *KVStoreSet) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*KVStoreSet) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *KVStoreSetResponse) EqualVT(that *KVStoreSetResponse) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Status.EqualVT(that.Status) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *KVStoreSetResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*KVStoreSetResponse) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *KVStoreDelete) EqualVT(that *KVStoreDelete) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Key != that.Key { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *KVStoreDelete) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*KVStoreDelete) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *KVStoreDeleteResponse) EqualVT(that *KVStoreDeleteResponse) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Status.EqualVT(that.Status) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *KVStoreDeleteResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*KVStoreDeleteResponse) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *KVStoreKeysResponse) EqualVT(that *KVStoreKeysResponse) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Status.EqualVT(that.Status) { + return false + } + if len(this.Keys) != len(that.Keys) { + return false + } + for i, vx := range this.Keys { + vy := that.Keys[i] + if vx != vy { + return false + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *KVStoreKeysResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*KVStoreKeysResponse) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *KVStoreGet) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreGet) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *KVStoreGet) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KVStoreGetResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreGetResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *KVStoreGetResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + if m.Status != nil { + size, err := m.Status.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KVStoreSet) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreSet) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *KVStoreSet) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KVStoreSetResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreSetResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *KVStoreSetResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Status != nil { + size, err := m.Status.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KVStoreDelete) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreDelete) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *KVStoreDelete) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KVStoreDeleteResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreDeleteResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *KVStoreDeleteResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Status != nil { + size, err := m.Status.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KVStoreKeysResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreKeysResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *KVStoreKeysResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Keys) > 0 { + for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Keys[iNdEx]) + copy(dAtA[i:], m.Keys[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Keys[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if m.Status != nil { + size, err := m.Status.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KVStoreGet) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreGet) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *KVStoreGet) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KVStoreGetResponse) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreGetResponse) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *KVStoreGetResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + if m.Status != nil { + size, err := m.Status.MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KVStoreSet) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreSet) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *KVStoreSet) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KVStoreSetResponse) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreSetResponse) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *KVStoreSetResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Status != nil { + size, err := m.Status.MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KVStoreDelete) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreDelete) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *KVStoreDelete) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KVStoreDeleteResponse) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreDeleteResponse) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *KVStoreDeleteResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Status != nil { + size, err := m.Status.MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KVStoreKeysResponse) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreKeysResponse) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *KVStoreKeysResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Keys) > 0 { + for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Keys[iNdEx]) + copy(dAtA[i:], m.Keys[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Keys[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if m.Status != nil { + size, err := m.Status.MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KVStoreGet) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *KVStoreGetResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != nil { + l = m.Status.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *KVStoreSet) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *KVStoreSetResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != nil { + l = m.Status.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *KVStoreDelete) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *KVStoreDeleteResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != nil { + l = m.Status.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *KVStoreKeysResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != nil { + l = m.Status.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.Keys) > 0 { + for _, s := range m.Keys { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *KVStoreGet) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreGet: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreGet: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KVStoreGetResponse) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreGetResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreGetResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &Status{} + } + if err := m.Status.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KVStoreSet) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreSet: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreSet: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KVStoreSetResponse) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreSetResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreSetResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &Status{} + } + if err := m.Status.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KVStoreDelete) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreDelete: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreDelete: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KVStoreDeleteResponse) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreDeleteResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreDeleteResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &Status{} + } + if err := m.Status.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KVStoreKeysResponse) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreKeysResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreKeysResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &Status{} + } + if err := m.Status.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Keys = append(m.Keys, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KVStoreGet) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreGet: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreGet: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + } + m.Key = stringValue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KVStoreGetResponse) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreGetResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreGetResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &Status{} + } + if err := m.Status.UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = dAtA[iNdEx:postIndex] + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KVStoreSet) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreSet: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreSet: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + } + m.Key = stringValue + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = dAtA[iNdEx:postIndex] + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KVStoreSetResponse) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreSetResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreSetResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &Status{} + } + if err := m.Status.UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KVStoreDelete) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreDelete: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreDelete: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + } + m.Key = stringValue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KVStoreDeleteResponse) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreDeleteResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreDeleteResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &Status{} + } + if err := m.Status.UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KVStoreKeysResponse) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreKeysResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreKeysResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &Status{} + } + if err := m.Status.UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + } + m.Keys = append(m.Keys, stringValue) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/proto/metrics.pb.go b/proto/metrics.pb.go new file mode 100644 index 00000000..0b583b90 --- /dev/null +++ b/proto/metrics.pb.go @@ -0,0 +1,301 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v5.27.1 +// source: metrics.proto + +package proto + +import ( + reflect "reflect" + sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// MetricsCounter is a structure used to create Counter metrics callback +// requests to the Tarmac Metrics interface. +type MetricsCounter struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Name is the name of the metric as exposed via the metrics HTTP end-point. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *MetricsCounter) Reset() { + *x = MetricsCounter{} + if protoimpl.UnsafeEnabled { + mi := &file_metrics_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MetricsCounter) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MetricsCounter) ProtoMessage() {} + +func (x *MetricsCounter) ProtoReflect() protoreflect.Message { + mi := &file_metrics_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MetricsCounter.ProtoReflect.Descriptor instead. +func (*MetricsCounter) Descriptor() ([]byte, []int) { + return file_metrics_proto_rawDescGZIP(), []int{0} +} + +func (x *MetricsCounter) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// MetricsGauge is a structure used to create Gauge metrics callback requests +// to the Tarmac Metrics interface. +type MetricsGauge struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Name is the name of the metric as exposed via the metrics HTTP end-point. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Action is the action to be performed for the Gauge metric. + // Valid options are inc (Increment) and dec (Decrement). + Action string `protobuf:"bytes,2,opt,name=action,proto3" json:"action,omitempty"` // inc or dec +} + +func (x *MetricsGauge) Reset() { + *x = MetricsGauge{} + if protoimpl.UnsafeEnabled { + mi := &file_metrics_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MetricsGauge) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MetricsGauge) ProtoMessage() {} + +func (x *MetricsGauge) ProtoReflect() protoreflect.Message { + mi := &file_metrics_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MetricsGauge.ProtoReflect.Descriptor instead. +func (*MetricsGauge) Descriptor() ([]byte, []int) { + return file_metrics_proto_rawDescGZIP(), []int{1} +} + +func (x *MetricsGauge) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *MetricsGauge) GetAction() string { + if x != nil { + return x.Action + } + return "" +} + +// MetricsHistogram is a structure used to create Histogram metrics callback +// requests to the Tarmac Metrics interface. +type MetricsHistogram struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Name is the name of the metric as exposed via the metrics HTTP end-point. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Value is the value to Observe for the Histogram metric. + Value float64 `protobuf:"fixed64,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *MetricsHistogram) Reset() { + *x = MetricsHistogram{} + if protoimpl.UnsafeEnabled { + mi := &file_metrics_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MetricsHistogram) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MetricsHistogram) ProtoMessage() {} + +func (x *MetricsHistogram) ProtoReflect() protoreflect.Message { + mi := &file_metrics_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MetricsHistogram.ProtoReflect.Descriptor instead. +func (*MetricsHistogram) Descriptor() ([]byte, []int) { + return file_metrics_proto_rawDescGZIP(), []int{2} +} + +func (x *MetricsHistogram) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *MetricsHistogram) GetValue() float64 { + if x != nil { + return x.Value + } + return 0 +} + +var File_metrics_proto protoreflect.FileDescriptor + +var file_metrics_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x0e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x22, + 0x24, 0x0a, 0x0e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, + 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, + 0x47, 0x61, 0x75, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x22, 0x3c, 0x0a, 0x10, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x48, 0x69, 0x73, 0x74, + 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, + 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x61, + 0x72, 0x6d, 0x61, 0x63, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x74, 0x61, 0x72, + 0x6d, 0x61, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_metrics_proto_rawDescOnce sync.Once + file_metrics_proto_rawDescData = file_metrics_proto_rawDesc +) + +func file_metrics_proto_rawDescGZIP() []byte { + file_metrics_proto_rawDescOnce.Do(func() { + file_metrics_proto_rawDescData = protoimpl.X.CompressGZIP(file_metrics_proto_rawDescData) + }) + return file_metrics_proto_rawDescData +} + +var file_metrics_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_metrics_proto_goTypes = []interface{}{ + (*MetricsCounter)(nil), // 0: tarmac.metrics.MetricsCounter + (*MetricsGauge)(nil), // 1: tarmac.metrics.MetricsGauge + (*MetricsHistogram)(nil), // 2: tarmac.metrics.MetricsHistogram +} +var file_metrics_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_metrics_proto_init() } +func file_metrics_proto_init() { + if File_metrics_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_metrics_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MetricsCounter); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_metrics_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MetricsGauge); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_metrics_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MetricsHistogram); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_metrics_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_metrics_proto_goTypes, + DependencyIndexes: file_metrics_proto_depIdxs, + MessageInfos: file_metrics_proto_msgTypes, + }.Build() + File_metrics_proto = out.File + file_metrics_proto_rawDesc = nil + file_metrics_proto_goTypes = nil + file_metrics_proto_depIdxs = nil +} diff --git a/proto/metrics_vtproto.pb.go b/proto/metrics_vtproto.pb.go new file mode 100644 index 00000000..3364d600 --- /dev/null +++ b/proto/metrics_vtproto.pb.go @@ -0,0 +1,1056 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.6.0 +// source: metrics.proto + +package proto + +import ( + binary "encoding/binary" + fmt "fmt" + io "io" + math "math" + unsafe "unsafe" + + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *MetricsCounter) CloneVT() *MetricsCounter { + if m == nil { + return (*MetricsCounter)(nil) + } + r := new(MetricsCounter) + r.Name = m.Name + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *MetricsCounter) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *MetricsGauge) CloneVT() *MetricsGauge { + if m == nil { + return (*MetricsGauge)(nil) + } + r := new(MetricsGauge) + r.Name = m.Name + r.Action = m.Action + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *MetricsGauge) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *MetricsHistogram) CloneVT() *MetricsHistogram { + if m == nil { + return (*MetricsHistogram)(nil) + } + r := new(MetricsHistogram) + r.Name = m.Name + r.Value = m.Value + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *MetricsHistogram) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (this *MetricsCounter) EqualVT(that *MetricsCounter) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Name != that.Name { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *MetricsCounter) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*MetricsCounter) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *MetricsGauge) EqualVT(that *MetricsGauge) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Name != that.Name { + return false + } + if this.Action != that.Action { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *MetricsGauge) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*MetricsGauge) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *MetricsHistogram) EqualVT(that *MetricsHistogram) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Name != that.Name { + return false + } + if this.Value != that.Value { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *MetricsHistogram) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*MetricsHistogram) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *MetricsCounter) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MetricsCounter) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *MetricsCounter) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MetricsGauge) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MetricsGauge) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *MetricsGauge) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Action) > 0 { + i -= len(m.Action) + copy(dAtA[i:], m.Action) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Action))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MetricsHistogram) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MetricsHistogram) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *MetricsHistogram) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Value != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) + i-- + dAtA[i] = 0x11 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MetricsCounter) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MetricsCounter) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *MetricsCounter) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MetricsGauge) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MetricsGauge) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *MetricsGauge) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Action) > 0 { + i -= len(m.Action) + copy(dAtA[i:], m.Action) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Action))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MetricsHistogram) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MetricsHistogram) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *MetricsHistogram) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Value != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) + i-- + dAtA[i] = 0x11 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MetricsCounter) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *MetricsGauge) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Action) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *MetricsHistogram) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Value != 0 { + n += 9 + } + n += len(m.unknownFields) + return n +} + +func (m *MetricsCounter) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MetricsCounter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MetricsCounter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MetricsGauge) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MetricsGauge: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MetricsGauge: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Action", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Action = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MetricsHistogram) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MetricsHistogram: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MetricsHistogram: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.Value = float64(math.Float64frombits(v)) + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MetricsCounter) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MetricsCounter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MetricsCounter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + } + m.Name = stringValue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MetricsGauge) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MetricsGauge: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MetricsGauge: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + } + m.Name = stringValue + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Action", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + } + m.Action = stringValue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MetricsHistogram) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MetricsHistogram: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MetricsHistogram: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + } + m.Name = stringValue + iNdEx = postIndex + case 2: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.Value = float64(math.Float64frombits(v)) + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/proto/sql.pb.go b/proto/sql.pb.go new file mode 100644 index 00000000..6cdf2dd4 --- /dev/null +++ b/proto/sql.pb.go @@ -0,0 +1,340 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v5.27.1 +// source: sql.proto + +package proto + +import ( + reflect "reflect" + sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// SQLQuery is a structure used to create SQL queries to a SQL Database. +type SQLQuery struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Query is the SQL Query to be executed. This field should be a byte slice + // to avoid conflicts with JSON encoding. + Query []byte `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"` +} + +func (x *SQLQuery) Reset() { + *x = SQLQuery{} + if protoimpl.UnsafeEnabled { + mi := &file_sql_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SQLQuery) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SQLQuery) ProtoMessage() {} + +func (x *SQLQuery) ProtoReflect() protoreflect.Message { + mi := &file_sql_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SQLQuery.ProtoReflect.Descriptor instead. +func (*SQLQuery) Descriptor() ([]byte, []int) { + return file_sql_proto_rawDescGZIP(), []int{0} +} + +func (x *SQLQuery) GetQuery() []byte { + if x != nil { + return x.Query + } + return nil +} + +// SQLQueryResponse is a structure supplied as a response message to a SQL +// Database Query. +type SQLQueryResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Status is the human readable error message or success message for function + // execution. + Status *Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` + // LastInsertID is the ID of the last inserted row. This field is only + // populated if the query was an insert query and the database supports + // returning the last inserted ID. + LastInsertId int64 `protobuf:"varint,2,opt,name=last_insert_id,json=lastInsertId,proto3" json:"last_insert_id,omitempty"` + // RowsAffected is the number of rows affected by the query. This field is + // only populated if the query was an insert, update, or delete query. + RowsAffected int64 `protobuf:"varint,3,opt,name=rows_affected,json=rowsAffected,proto3" json:"rows_affected,omitempty"` + // Columns is a list of column names returned by the query. This field is + // only populated if the query was a select query. + Columns []string `protobuf:"bytes,4,rep,name=columns,proto3" json:"columns,omitempty"` + // Rows is a list of rows returned by the query. This field is only populated + // if the query was a select query. + Rows []*Row `protobuf:"bytes,5,rep,name=rows,proto3" json:"rows,omitempty"` +} + +func (x *SQLQueryResponse) Reset() { + *x = SQLQueryResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_sql_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SQLQueryResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SQLQueryResponse) ProtoMessage() {} + +func (x *SQLQueryResponse) ProtoReflect() protoreflect.Message { + mi := &file_sql_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SQLQueryResponse.ProtoReflect.Descriptor instead. +func (*SQLQueryResponse) Descriptor() ([]byte, []int) { + return file_sql_proto_rawDescGZIP(), []int{1} +} + +func (x *SQLQueryResponse) GetStatus() *Status { + if x != nil { + return x.Status + } + return nil +} + +func (x *SQLQueryResponse) GetLastInsertId() int64 { + if x != nil { + return x.LastInsertId + } + return 0 +} + +func (x *SQLQueryResponse) GetRowsAffected() int64 { + if x != nil { + return x.RowsAffected + } + return 0 +} + +func (x *SQLQueryResponse) GetColumns() []string { + if x != nil { + return x.Columns + } + return nil +} + +func (x *SQLQueryResponse) GetRows() []*Row { + if x != nil { + return x.Rows + } + return nil +} + +// Row is a structure used to represent a row in a SQL query response. +// The data field is a map of column names to column values. +type Row struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data map[string][]byte `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *Row) Reset() { + *x = Row{} + if protoimpl.UnsafeEnabled { + mi := &file_sql_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Row) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Row) ProtoMessage() {} + +func (x *Row) ProtoReflect() protoreflect.Message { + mi := &file_sql_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Row.ProtoReflect.Descriptor instead. +func (*Row) Descriptor() ([]byte, []int) { + return file_sql_proto_rawDescGZIP(), []int{2} +} + +func (x *Row) GetData() map[string][]byte { + if x != nil { + return x.Data + } + return nil +} + +var File_sql_proto protoreflect.FileDescriptor + +var file_sql_proto_rawDesc = []byte{ + 0x0a, 0x09, 0x73, 0x71, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x74, 0x61, 0x72, + 0x6d, 0x61, 0x63, 0x2e, 0x73, 0x71, 0x6c, 0x1a, 0x0c, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x20, 0x0a, 0x08, 0x53, 0x51, 0x4c, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x22, 0xc4, 0x01, 0x0a, 0x10, 0x53, 0x51, 0x4c, 0x51, + 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, + 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x69, 0x6e, 0x73, + 0x65, 0x72, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6c, 0x61, + 0x73, 0x74, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x6f, + 0x77, 0x73, 0x5f, 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x0c, 0x72, 0x6f, 0x77, 0x73, 0x41, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, + 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x23, 0x0a, 0x04, 0x72, 0x6f, 0x77, + 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, + 0x2e, 0x73, 0x71, 0x6c, 0x2e, 0x52, 0x6f, 0x77, 0x52, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x22, 0x6d, + 0x0a, 0x03, 0x52, 0x6f, 0x77, 0x12, 0x2d, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x73, 0x71, 0x6c, + 0x2e, 0x52, 0x6f, 0x77, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x1a, 0x37, 0x0a, 0x09, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x28, 0x5a, + 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x61, 0x72, 0x6d, + 0x61, 0x63, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, + 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_sql_proto_rawDescOnce sync.Once + file_sql_proto_rawDescData = file_sql_proto_rawDesc +) + +func file_sql_proto_rawDescGZIP() []byte { + file_sql_proto_rawDescOnce.Do(func() { + file_sql_proto_rawDescData = protoimpl.X.CompressGZIP(file_sql_proto_rawDescData) + }) + return file_sql_proto_rawDescData +} + +var file_sql_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_sql_proto_goTypes = []interface{}{ + (*SQLQuery)(nil), // 0: tarmac.sql.SQLQuery + (*SQLQueryResponse)(nil), // 1: tarmac.sql.SQLQueryResponse + (*Row)(nil), // 2: tarmac.sql.Row + nil, // 3: tarmac.sql.Row.DataEntry + (*Status)(nil), // 4: tarmac.Status +} +var file_sql_proto_depIdxs = []int32{ + 4, // 0: tarmac.sql.SQLQueryResponse.status:type_name -> tarmac.Status + 2, // 1: tarmac.sql.SQLQueryResponse.rows:type_name -> tarmac.sql.Row + 3, // 2: tarmac.sql.Row.data:type_name -> tarmac.sql.Row.DataEntry + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_sql_proto_init() } +func file_sql_proto_init() { + if File_sql_proto != nil { + return + } + file_tarmac_proto_init() + if !protoimpl.UnsafeEnabled { + file_sql_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SQLQuery); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sql_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SQLQueryResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sql_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Row); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_sql_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_sql_proto_goTypes, + DependencyIndexes: file_sql_proto_depIdxs, + MessageInfos: file_sql_proto_msgTypes, + }.Build() + File_sql_proto = out.File + file_sql_proto_rawDesc = nil + file_sql_proto_goTypes = nil + file_sql_proto_depIdxs = nil +} diff --git a/proto/sql_vtproto.pb.go b/proto/sql_vtproto.pb.go new file mode 100644 index 00000000..c209a2f0 --- /dev/null +++ b/proto/sql_vtproto.pb.go @@ -0,0 +1,1509 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.6.0 +// source: sql.proto + +package proto + +import ( + fmt "fmt" + io "io" + unsafe "unsafe" + + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *SQLQuery) CloneVT() *SQLQuery { + if m == nil { + return (*SQLQuery)(nil) + } + r := new(SQLQuery) + if rhs := m.Query; rhs != nil { + tmpBytes := make([]byte, len(rhs)) + copy(tmpBytes, rhs) + r.Query = tmpBytes + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *SQLQuery) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *SQLQueryResponse) CloneVT() *SQLQueryResponse { + if m == nil { + return (*SQLQueryResponse)(nil) + } + r := new(SQLQueryResponse) + r.Status = m.Status.CloneVT() + r.LastInsertId = m.LastInsertId + r.RowsAffected = m.RowsAffected + if rhs := m.Columns; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.Columns = tmpContainer + } + if rhs := m.Rows; rhs != nil { + tmpContainer := make([]*Row, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Rows = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *SQLQueryResponse) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *Row) CloneVT() *Row { + if m == nil { + return (*Row)(nil) + } + r := new(Row) + if rhs := m.Data; rhs != nil { + tmpContainer := make(map[string][]byte, len(rhs)) + for k, v := range rhs { + tmpBytes := make([]byte, len(v)) + copy(tmpBytes, v) + tmpContainer[k] = tmpBytes + } + r.Data = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Row) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (this *SQLQuery) EqualVT(that *SQLQuery) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if string(this.Query) != string(that.Query) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SQLQuery) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SQLQuery) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *SQLQueryResponse) EqualVT(that *SQLQueryResponse) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Status.EqualVT(that.Status) { + return false + } + if this.LastInsertId != that.LastInsertId { + return false + } + if this.RowsAffected != that.RowsAffected { + return false + } + if len(this.Columns) != len(that.Columns) { + return false + } + for i, vx := range this.Columns { + vy := that.Columns[i] + if vx != vy { + return false + } + } + if len(this.Rows) != len(that.Rows) { + return false + } + for i, vx := range this.Rows { + vy := that.Rows[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &Row{} + } + if q == nil { + q = &Row{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SQLQueryResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SQLQueryResponse) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *Row) EqualVT(that *Row) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Data) != len(that.Data) { + return false + } + for i, vx := range this.Data { + vy, ok := that.Data[i] + if !ok { + return false + } + if string(vx) != string(vy) { + return false + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Row) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Row) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *SQLQuery) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SQLQuery) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SQLQuery) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Query) > 0 { + i -= len(m.Query) + copy(dAtA[i:], m.Query) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Query))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SQLQueryResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SQLQueryResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SQLQueryResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Rows) > 0 { + for iNdEx := len(m.Rows) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Rows[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + } + if len(m.Columns) > 0 { + for iNdEx := len(m.Columns) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Columns[iNdEx]) + copy(dAtA[i:], m.Columns[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Columns[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if m.RowsAffected != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.RowsAffected)) + i-- + dAtA[i] = 0x18 + } + if m.LastInsertId != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.LastInsertId)) + i-- + dAtA[i] = 0x10 + } + if m.Status != nil { + size, err := m.Status.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Row) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Row) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Row) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Data) > 0 { + for k := range m.Data { + v := m.Data[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *SQLQuery) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SQLQuery) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *SQLQuery) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Query) > 0 { + i -= len(m.Query) + copy(dAtA[i:], m.Query) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Query))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SQLQueryResponse) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SQLQueryResponse) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *SQLQueryResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Rows) > 0 { + for iNdEx := len(m.Rows) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Rows[iNdEx].MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + } + if len(m.Columns) > 0 { + for iNdEx := len(m.Columns) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Columns[iNdEx]) + copy(dAtA[i:], m.Columns[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Columns[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if m.RowsAffected != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.RowsAffected)) + i-- + dAtA[i] = 0x18 + } + if m.LastInsertId != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.LastInsertId)) + i-- + dAtA[i] = 0x10 + } + if m.Status != nil { + size, err := m.Status.MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Row) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Row) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *Row) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Data) > 0 { + for k := range m.Data { + v := m.Data[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *SQLQuery) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Query) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *SQLQueryResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != nil { + l = m.Status.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.LastInsertId != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.LastInsertId)) + } + if m.RowsAffected != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.RowsAffected)) + } + if len(m.Columns) > 0 { + for _, s := range m.Columns { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if len(m.Rows) > 0 { + for _, e := range m.Rows { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *Row) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Data) > 0 { + for k, v := range m.Data { + _ = k + _ = v + l = 1 + len(v) + protohelpers.SizeOfVarint(uint64(len(v))) + mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + l + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *SQLQuery) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SQLQuery: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SQLQuery: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Query = append(m.Query[:0], dAtA[iNdEx:postIndex]...) + if m.Query == nil { + m.Query = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SQLQueryResponse) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SQLQueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SQLQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &Status{} + } + if err := m.Status.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastInsertId", wireType) + } + m.LastInsertId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastInsertId |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RowsAffected", wireType) + } + m.RowsAffected = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RowsAffected |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Columns", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Columns = append(m.Columns, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rows", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rows = append(m.Rows, &Row{}) + if err := m.Rows[len(m.Rows)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Row) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Row: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Row: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Data == nil { + m.Data = make(map[string][]byte) + } + var mapkey string + var mapvalue []byte + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapbyteLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapbyteLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intMapbyteLen := int(mapbyteLen) + if intMapbyteLen < 0 { + return protohelpers.ErrInvalidLength + } + postbytesIndex := iNdEx + intMapbyteLen + if postbytesIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postbytesIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = make([]byte, mapbyteLen) + copy(mapvalue, dAtA[iNdEx:postbytesIndex]) + iNdEx = postbytesIndex + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Data[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SQLQuery) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SQLQuery: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SQLQuery: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Query = dAtA[iNdEx:postIndex] + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SQLQueryResponse) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SQLQueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SQLQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &Status{} + } + if err := m.Status.UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastInsertId", wireType) + } + m.LastInsertId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastInsertId |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RowsAffected", wireType) + } + m.RowsAffected = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RowsAffected |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Columns", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + } + m.Columns = append(m.Columns, stringValue) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rows", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rows = append(m.Rows, &Row{}) + if err := m.Rows[len(m.Rows)-1].UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Row) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Row: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Row: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Data == nil { + m.Data = make(map[string][]byte) + } + var mapkey string + var mapvalue []byte + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + if intStringLenmapkey == 0 { + mapkey = "" + } else { + mapkey = unsafe.String(&dAtA[iNdEx], intStringLenmapkey) + } + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapbyteLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapbyteLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intMapbyteLen := int(mapbyteLen) + if intMapbyteLen < 0 { + return protohelpers.ErrInvalidLength + } + postbytesIndex := iNdEx + intMapbyteLen + if postbytesIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postbytesIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = dAtA[iNdEx:postbytesIndex] + iNdEx = postbytesIndex + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Data[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/proto/tarmac.pb.go b/proto/tarmac.pb.go new file mode 100644 index 00000000..5d1818bd --- /dev/null +++ b/proto/tarmac.pb.go @@ -0,0 +1,164 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v5.27.1 +// source: tarmac.proto + +package proto + +import ( + reflect "reflect" + sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Status is used to return a status code and message to clients when +// performing host callbacks to Tarmac. +// +// The status code will indicate failure or success. +// +// Status codes are as follows: +// 000 - Success +// 100 - Failure +type Status struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Code is the status code for callback execution. + Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` + // Status is the human readable error message or success message for function + // execution. + Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` +} + +func (x *Status) Reset() { + *x = Status{} + if protoimpl.UnsafeEnabled { + mi := &file_tarmac_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Status) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Status) ProtoMessage() {} + +func (x *Status) ProtoReflect() protoreflect.Message { + mi := &file_tarmac_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Status.ProtoReflect.Descriptor instead. +func (*Status) Descriptor() ([]byte, []int) { + return file_tarmac_proto_rawDescGZIP(), []int{0} +} + +func (x *Status) GetCode() int32 { + if x != nil { + return x.Code + } + return 0 +} + +func (x *Status) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +var File_tarmac_proto protoreflect.FileDescriptor + +var file_tarmac_proto_rawDesc = []byte{ + 0x0a, 0x0c, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, + 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x22, 0x34, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, + 0x63, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x28, 0x5a, 0x26, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, + 0x63, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_tarmac_proto_rawDescOnce sync.Once + file_tarmac_proto_rawDescData = file_tarmac_proto_rawDesc +) + +func file_tarmac_proto_rawDescGZIP() []byte { + file_tarmac_proto_rawDescOnce.Do(func() { + file_tarmac_proto_rawDescData = protoimpl.X.CompressGZIP(file_tarmac_proto_rawDescData) + }) + return file_tarmac_proto_rawDescData +} + +var file_tarmac_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_tarmac_proto_goTypes = []interface{}{ + (*Status)(nil), // 0: tarmac.Status +} +var file_tarmac_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_tarmac_proto_init() } +func file_tarmac_proto_init() { + if File_tarmac_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_tarmac_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Status); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_tarmac_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_tarmac_proto_goTypes, + DependencyIndexes: file_tarmac_proto_depIdxs, + MessageInfos: file_tarmac_proto_msgTypes, + }.Build() + File_tarmac_proto = out.File + file_tarmac_proto_rawDesc = nil + file_tarmac_proto_goTypes = nil + file_tarmac_proto_depIdxs = nil +} diff --git a/proto/tarmac_vtproto.pb.go b/proto/tarmac_vtproto.pb.go new file mode 100644 index 00000000..a9f99e24 --- /dev/null +++ b/proto/tarmac_vtproto.pb.go @@ -0,0 +1,378 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.6.0 +// source: tarmac.proto + +package proto + +import ( + fmt "fmt" + io "io" + unsafe "unsafe" + + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *Status) CloneVT() *Status { + if m == nil { + return (*Status)(nil) + } + r := new(Status) + r.Code = m.Code + r.Status = m.Status + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Status) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (this *Status) EqualVT(that *Status) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Code != that.Code { + return false + } + if this.Status != that.Status { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Status) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Status) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *Status) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Status) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Status) > 0 { + i -= len(m.Status) + copy(dAtA[i:], m.Status) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Status))) + i-- + dAtA[i] = 0x12 + } + if m.Code != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Code)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Status) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Status) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *Status) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Status) > 0 { + i -= len(m.Status) + copy(dAtA[i:], m.Status) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Status))) + i-- + dAtA[i] = 0x12 + } + if m.Code != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Code)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Status) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Code != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Code)) + } + l = len(m.Status) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *Status) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Status: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Status: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + m.Code = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Code |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Status = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Status) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Status: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Status: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + m.Code = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Code |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + } + m.Status = stringValue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} From 68a66bee3764b7aab40416ce8f1aebba4697fb1f Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sat, 17 Aug 2024 11:02:37 -0700 Subject: [PATCH 03/31] working SQL query --- pkg/callbacks/sql/sql.go | 205 +++---- pkg/callbacks/sql/sql_test.go | 21 +- proto/http.pb.go | 15 +- proto/http_vtproto.pb.go | 5 +- proto/kvstore.pb.go | 25 +- proto/kvstore_vtproto.pb.go | 5 +- proto/metrics.pb.go | 17 +- proto/metrics_vtproto.pb.go | 7 +- proto/sql.pb.go | 258 +++++---- proto/sql_vtproto.pb.go | 974 ++++++++++++++++++---------------- proto/tarmac.pb.go | 13 +- proto/tarmac_vtproto.pb.go | 5 +- 12 files changed, 793 insertions(+), 757 deletions(-) diff --git a/pkg/callbacks/sql/sql.go b/pkg/callbacks/sql/sql.go index 75b308d0..62139d9a 100644 --- a/pkg/callbacks/sql/sql.go +++ b/pkg/callbacks/sql/sql.go @@ -67,7 +67,8 @@ func (db *Database) Query(b []byte) ([]byte, error) { return db.queryJSON(b) } - r := proto.SQLQueryResponse{} + // Create a new SQLQueryResponse + r := &proto.SQLQueryResponse{} r.Status = &proto.Status{Code: 200, Status: "OK"} if len(msg.Query) < 1 { @@ -76,89 +77,31 @@ func (db *Database) Query(b []byte) ([]byte, error) { } if r.Status.Code == 200 { - rows, err := db.db.Query(msg.Query) + columns, results, err := db.query(msg.Query) if err != nil { r.Status.Code = 500 r.Status.Status = fmt.Sprintf("Unable to execute query - %s", err) } - defer rows.Close() - - if r.Status.Code == 200 { - - // Set last insert ID - lastID, err := rows.LastInsertId() - if err != nil { - r.Status.Code = 500 - r.Status.Status = fmt.Sprintf("Unable to get last insert ID - %s", err) - } - - if r.Status.Code == 200 { - r.LastInsertID = lastID - } - - // Set number of rows affected - rowsAffected, err := rows.RowsAffected() - if err != nil { - r.Status.Code = 500 - r.Status.Status = fmt.Sprintf("Unable to get rows affected - %s", err) - } - - if r.Status.Code == 200 { - r.RowsAffected = rowsAffected - } - - // Grab Colummns - columns, err := rows.Columns() - if err != nil { - r.Status.Code = 500 - r.Status.Status = fmt.Sprintf("Unable to process query results - %s", err) - } - r.Columns = columns - - // Loop through results - if len(columns) > 0 { - pbRows := []*proto.Row{} - for rows.Next() { - pbRow := proto.Row{} - data := make(map[string][]byte) - rawdata := make([]*sql.RawBytes, len(columns)) - for i := range columns { - rawdata[i] = new(sql.RawBytes) - } - - err := rows.Scan(rawdata...) - if err != nil { - r.Status.Code = 500 - r.Status.Status = fmt.Sprintf("Unable to process query results - %s", err) - } - - for i, raw := range rawdata { - if raw != nil { - data[columns[i]] = *raw - } - } - - if r.Status.Code == 200 { - pbRow.Data = data - pbRows = append(pbRows, &pbRow) - } - } - r.Rows = pbRows - } - } - // Marshal a resposne - rsp, err := pb.Marshal(&r) + // Marshal results into JSON bytes + j, err := ffjson.Marshal(results) if err != nil { - return []byte(""), fmt.Errorf("unable to marshal database:query response") + r.Status.Code = 500 + r.Status.Status = fmt.Sprintf("Unable to convert query results to JSON - %s", err) } - // Return response to caller - if r.Status.Code == 200 { - return rsp, nil - } - return rsp, fmt.Errorf("%s", r.Status.Status) + // Set the response data + r.Data = j + r.Columns = columns } + + // Marshal a response Proto to return to caller + rsp, err := pb.Marshal(r) + if err != nil { + return []byte(""), fmt.Errorf("unable to marshal database:query response") + } + + return rsp, nil } // queryJSON retains the JSON interface for backwards compatibility with the Tarmac Host Callback interface. @@ -189,66 +132,21 @@ func (db *Database) queryJSON(b []byte) ([]byte, error) { } if r.Status.Code == 200 { - var results []map[string]interface{} - - // Query database - rows, err := db.db.Query(string(q)) + _, results, err := db.query(q) if err != nil { r.Status.Code = 500 r.Status.Status = fmt.Sprintf("Unable to execute query - %s", err) } - if r.Status.Code == 200 { - defer rows.Close() - - // Grab column details for result processing - columns, err := rows.ColumnTypes() - if err != nil { - r.Status.Code = 500 - r.Status.Status = fmt.Sprintf("Unable to process query results - %s", err) - } - - if len(columns) > 0 { - // Loop through results creating a list of maps - for rows.Next() { - colNames := make([]interface{}, len(columns)) - data := make([]interface{}, len(columns)) - for i := range colNames { - data[i] = &colNames[i] - } - - // Extract data from results - err := rows.Scan(data...) - if err != nil { - r.Status.Code = 500 - r.Status.Status = fmt.Sprintf("Unable to process query results - %s", err) - } - - // Create a map for simple access to data - m := make(map[string]interface{}) - for i, c := range columns { - m[c.Name()] = data[i] - } - - // Append to final results - results = append(results, m) - } - if rows.Err() != nil { - r.Status.Code = 500 - r.Status.Status = fmt.Sprintf("Error while processing query results - %s", rows.Err()) - } - - // Convert results into JSON - j, err := ffjson.Marshal(results) - if err != nil { - r.Status.Code = 500 - r.Status.Status = fmt.Sprintf("Unable to convert query results to JSON - %s", err) - } - - // Base64 encode results to avoid JSON format conflicts - r.Data = base64.StdEncoding.EncodeToString(j) - } + // Convert results into JSON + j, err := ffjson.Marshal(results) + if err != nil { + r.Status.Code = 500 + r.Status.Status = fmt.Sprintf("Unable to convert query results to JSON - %s", err) } + + // Base64 encode results to avoid JSON format conflicts + r.Data = base64.StdEncoding.EncodeToString(j) } // Marshal a resposne JSON to return to caller @@ -262,3 +160,52 @@ func (db *Database) queryJSON(b []byte) ([]byte, error) { } return rsp, fmt.Errorf("%s", r.Status.Status) } + +// Query will execute the supplied query against the database and return +// the rows as a list of maps. The keys in the map are the column names +// and the values are the column values. +func (db *Database) query(qry []byte) ([]string, []map[string]any, error) { + + rows, err := db.db.Query(fmt.Sprintf("%s", qry)) + if err != nil { + return nil, nil, fmt.Errorf("unable to execute query - %s", err) + } + defer rows.Close() + + columns, err := rows.Columns() + if err != nil { + return nil, nil, fmt.Errorf("unable to process query results - %s", err) + } + + var results []map[string]any + + for rows.Next() { + colNames := make([]interface{}, len(columns)) + data := make([]interface{}, len(columns)) + for i := range colNames { + data[i] = &colNames[i] + } + + err := rows.Scan(data...) + if err != nil { + return nil, nil, fmt.Errorf("unable to process query results - %s", err) + } + + m := make(map[string]any) + for i, c := range columns { + m[c] = data[i] + } + + results = append(results, m) + } + + if rows.Err() != nil { + return nil, nil, fmt.Errorf("error while processing query results - %s", rows.Err()) + } + + return columns, results, nil +} + +func (db *Database) exec(qry []byte) (sql.Result, error) { + return nil, fmt.Errorf("not implemented") +} diff --git a/pkg/callbacks/sql/sql_test.go b/pkg/callbacks/sql/sql_test.go index e8558d40..ab129760 100644 --- a/pkg/callbacks/sql/sql_test.go +++ b/pkg/callbacks/sql/sql_test.go @@ -98,7 +98,7 @@ func TestSQLQuery(t *testing.T) { t.Run("Happy Path", func(t *testing.T) { t.Run("Create Table", func(t *testing.T) { - query := &proto.SQLQuery{Query: []byte(`CREATE TABLE IF NOT EXISTS testpkg ( id int NOT NULL, name varchar(255), PRIMARY KEY (id) );`)} + query := &proto.SQLExec{Query: []byte(`CREATE TABLE IF NOT EXISTS testpkg ( id int NOT NULL, name varchar(255), PRIMARY KEY (id) );`)} qMsg, err := pb.Marshal(query) if err != nil { t.Fatalf("Unable to marshal query message") @@ -110,7 +110,7 @@ func TestSQLQuery(t *testing.T) { } // Unmarshal the Tarmac Response - var rsp proto.SQLQueryResponse + var rsp proto.SQLExecResponse err = pb.Unmarshal(r, &rsp) if err != nil { t.Fatalf("Error parsing returned query response") @@ -123,7 +123,7 @@ func TestSQLQuery(t *testing.T) { }) t.Run("Insert Data", func(t *testing.T) { - query := &proto.SQLQuery{Query: []byte(`INSERT INTO testpkg (id, name) VALUES (1, "John Smith");`)} + query := &proto.SQLExec{Query: []byte(`INSERT INTO testpkg (id, name) VALUES (1, "John Smith");`)} qMsg, err := pb.Marshal(query) if err != nil { t.Fatalf("Unable to marshal query message") @@ -135,7 +135,7 @@ func TestSQLQuery(t *testing.T) { } // Unmarshal the Tarmac Response - var rsp proto.SQLQueryResponse + var rsp proto.SQLExecResponse err = pb.Unmarshal(r, &rsp) if err != nil { t.Fatalf("Error parsing returned query response") @@ -187,20 +187,15 @@ func TestSQLQuery(t *testing.T) { t.Fatalf("Unexpected number of columns returned - %d", len(rsp.Columns)) } - // Verify Rows - if len(rsp.Rows) != 1 { - t.Fatalf("Unexpected number of rows returned - %d", len(rsp.Rows)) - } - // Verify Data - if string(rsp.Rows[0].Data["id"]) != "1" && string(rsp.Rows[0].Data["name"]) != "John Smith" { - t.Fatalf("Unexpected data returned - %v", rsp.Rows[0].Data) + if len(rsp.Data) == 0 { + t.Fatalf("No data returned from query") } }) t.Run("Delete Table", func(t *testing.T) { - query := &proto.SQLQuery{Query: []byte(`DROP TABLE IF EXISTS testpkg;`)} + query := &proto.SQLExec{Query: []byte(`DROP TABLE IF EXISTS testpkg;`)} qMsg, err := pb.Marshal(query) if err != nil { t.Fatalf("Unable to marshal query message") @@ -212,7 +207,7 @@ func TestSQLQuery(t *testing.T) { } // Unmarshal the Tarmac Response - var rsp proto.SQLQueryResponse + var rsp proto.SQLExecResponse err = pb.Unmarshal(r, &rsp) if err != nil { t.Fatalf("Error parsing returned query response") diff --git a/proto/http.pb.go b/proto/http.pb.go index 6cfdd0ff..d1224a31 100644 --- a/proto/http.pb.go +++ b/proto/http.pb.go @@ -1,17 +1,16 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v5.27.1 +// protoc-gen-go v1.34.2 +// protoc v5.27.3 // source: http.proto package proto import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( @@ -241,7 +240,7 @@ func file_http_proto_rawDescGZIP() []byte { } var file_http_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_http_proto_goTypes = []interface{}{ +var file_http_proto_goTypes = []any{ (*HTTPClient)(nil), // 0: tarmac.http.HTTPClient (*HTTPClientResponse)(nil), // 1: tarmac.http.HTTPClientResponse nil, // 2: tarmac.http.HTTPClient.HeadersEntry @@ -266,7 +265,7 @@ func file_http_proto_init() { } file_tarmac_proto_init() if !protoimpl.UnsafeEnabled { - file_http_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_http_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*HTTPClient); i { case 0: return &v.state @@ -278,7 +277,7 @@ func file_http_proto_init() { return nil } } - file_http_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_http_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*HTTPClientResponse); i { case 0: return &v.state diff --git a/proto/http_vtproto.pb.go b/proto/http_vtproto.pb.go index 881f9b68..ab3a2edb 100644 --- a/proto/http_vtproto.pb.go +++ b/proto/http_vtproto.pb.go @@ -6,12 +6,11 @@ package proto import ( fmt "fmt" - io "io" - unsafe "unsafe" - protohelpers "github.com/planetscale/vtprotobuf/protohelpers" proto "google.golang.org/protobuf/proto" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + unsafe "unsafe" ) const ( diff --git a/proto/kvstore.pb.go b/proto/kvstore.pb.go index b2c19bea..82e9db7d 100644 --- a/proto/kvstore.pb.go +++ b/proto/kvstore.pb.go @@ -1,17 +1,16 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v5.27.1 +// protoc-gen-go v1.34.2 +// protoc v5.27.3 // source: kvstore.proto package proto import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( @@ -472,7 +471,7 @@ func file_kvstore_proto_rawDescGZIP() []byte { } var file_kvstore_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_kvstore_proto_goTypes = []interface{}{ +var file_kvstore_proto_goTypes = []any{ (*KVStoreGet)(nil), // 0: tarmac.kvstore.KVStoreGet (*KVStoreGetResponse)(nil), // 1: tarmac.kvstore.KVStoreGetResponse (*KVStoreSet)(nil), // 2: tarmac.kvstore.KVStoreSet @@ -501,7 +500,7 @@ func file_kvstore_proto_init() { } file_tarmac_proto_init() if !protoimpl.UnsafeEnabled { - file_kvstore_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_kvstore_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*KVStoreGet); i { case 0: return &v.state @@ -513,7 +512,7 @@ func file_kvstore_proto_init() { return nil } } - file_kvstore_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_kvstore_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*KVStoreGetResponse); i { case 0: return &v.state @@ -525,7 +524,7 @@ func file_kvstore_proto_init() { return nil } } - file_kvstore_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_kvstore_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*KVStoreSet); i { case 0: return &v.state @@ -537,7 +536,7 @@ func file_kvstore_proto_init() { return nil } } - file_kvstore_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_kvstore_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*KVStoreSetResponse); i { case 0: return &v.state @@ -549,7 +548,7 @@ func file_kvstore_proto_init() { return nil } } - file_kvstore_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_kvstore_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*KVStoreDelete); i { case 0: return &v.state @@ -561,7 +560,7 @@ func file_kvstore_proto_init() { return nil } } - file_kvstore_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_kvstore_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*KVStoreDeleteResponse); i { case 0: return &v.state @@ -573,7 +572,7 @@ func file_kvstore_proto_init() { return nil } } - file_kvstore_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_kvstore_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*KVStoreKeysResponse); i { case 0: return &v.state diff --git a/proto/kvstore_vtproto.pb.go b/proto/kvstore_vtproto.pb.go index b51e2699..7cfb1c67 100644 --- a/proto/kvstore_vtproto.pb.go +++ b/proto/kvstore_vtproto.pb.go @@ -6,12 +6,11 @@ package proto import ( fmt "fmt" - io "io" - unsafe "unsafe" - protohelpers "github.com/planetscale/vtprotobuf/protohelpers" proto "google.golang.org/protobuf/proto" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + unsafe "unsafe" ) const ( diff --git a/proto/metrics.pb.go b/proto/metrics.pb.go index 0b583b90..70ccd602 100644 --- a/proto/metrics.pb.go +++ b/proto/metrics.pb.go @@ -1,17 +1,16 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v5.27.1 +// protoc-gen-go v1.34.2 +// protoc v5.27.3 // source: metrics.proto package proto import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( @@ -224,7 +223,7 @@ func file_metrics_proto_rawDescGZIP() []byte { } var file_metrics_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_metrics_proto_goTypes = []interface{}{ +var file_metrics_proto_goTypes = []any{ (*MetricsCounter)(nil), // 0: tarmac.metrics.MetricsCounter (*MetricsGauge)(nil), // 1: tarmac.metrics.MetricsGauge (*MetricsHistogram)(nil), // 2: tarmac.metrics.MetricsHistogram @@ -243,7 +242,7 @@ func file_metrics_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_metrics_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_metrics_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*MetricsCounter); i { case 0: return &v.state @@ -255,7 +254,7 @@ func file_metrics_proto_init() { return nil } } - file_metrics_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_metrics_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*MetricsGauge); i { case 0: return &v.state @@ -267,7 +266,7 @@ func file_metrics_proto_init() { return nil } } - file_metrics_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_metrics_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*MetricsHistogram); i { case 0: return &v.state diff --git a/proto/metrics_vtproto.pb.go b/proto/metrics_vtproto.pb.go index 3364d600..32297228 100644 --- a/proto/metrics_vtproto.pb.go +++ b/proto/metrics_vtproto.pb.go @@ -7,13 +7,12 @@ package proto import ( binary "encoding/binary" fmt "fmt" - io "io" - math "math" - unsafe "unsafe" - protohelpers "github.com/planetscale/vtprotobuf/protohelpers" proto "google.golang.org/protobuf/proto" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + math "math" + unsafe "unsafe" ) const ( diff --git a/proto/sql.pb.go b/proto/sql.pb.go index 6cdf2dd4..65315e1d 100644 --- a/proto/sql.pb.go +++ b/proto/sql.pb.go @@ -1,17 +1,16 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v5.27.1 +// protoc-gen-go v1.34.2 +// protoc v5.27.3 // source: sql.proto package proto import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( @@ -21,8 +20,9 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// SQLQuery is a structure used to create SQL queries to a SQL Database. -type SQLQuery struct { +// SQLExec is a structure used to execute a SQL query on a SQL Database. +// This message type should be leveraged for queries that do not return rows. +type SQLExec struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -32,8 +32,8 @@ type SQLQuery struct { Query []byte `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"` } -func (x *SQLQuery) Reset() { - *x = SQLQuery{} +func (x *SQLExec) Reset() { + *x = SQLExec{} if protoimpl.UnsafeEnabled { mi := &file_sql_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -41,13 +41,13 @@ func (x *SQLQuery) Reset() { } } -func (x *SQLQuery) String() string { +func (x *SQLExec) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SQLQuery) ProtoMessage() {} +func (*SQLExec) ProtoMessage() {} -func (x *SQLQuery) ProtoReflect() protoreflect.Message { +func (x *SQLExec) ProtoReflect() protoreflect.Message { mi := &file_sql_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -59,21 +59,21 @@ func (x *SQLQuery) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SQLQuery.ProtoReflect.Descriptor instead. -func (*SQLQuery) Descriptor() ([]byte, []int) { +// Deprecated: Use SQLExec.ProtoReflect.Descriptor instead. +func (*SQLExec) Descriptor() ([]byte, []int) { return file_sql_proto_rawDescGZIP(), []int{0} } -func (x *SQLQuery) GetQuery() []byte { +func (x *SQLExec) GetQuery() []byte { if x != nil { return x.Query } return nil } -// SQLQueryResponse is a structure supplied as a response message to a SQL -// Database Query. -type SQLQueryResponse struct { +// SQLExecResponse is a structure supplied as a response message to a SQLExec +// request. +type SQLExecResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -88,16 +88,10 @@ type SQLQueryResponse struct { // RowsAffected is the number of rows affected by the query. This field is // only populated if the query was an insert, update, or delete query. RowsAffected int64 `protobuf:"varint,3,opt,name=rows_affected,json=rowsAffected,proto3" json:"rows_affected,omitempty"` - // Columns is a list of column names returned by the query. This field is - // only populated if the query was a select query. - Columns []string `protobuf:"bytes,4,rep,name=columns,proto3" json:"columns,omitempty"` - // Rows is a list of rows returned by the query. This field is only populated - // if the query was a select query. - Rows []*Row `protobuf:"bytes,5,rep,name=rows,proto3" json:"rows,omitempty"` } -func (x *SQLQueryResponse) Reset() { - *x = SQLQueryResponse{} +func (x *SQLExecResponse) Reset() { + *x = SQLExecResponse{} if protoimpl.UnsafeEnabled { mi := &file_sql_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -105,13 +99,13 @@ func (x *SQLQueryResponse) Reset() { } } -func (x *SQLQueryResponse) String() string { +func (x *SQLExecResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SQLQueryResponse) ProtoMessage() {} +func (*SQLExecResponse) ProtoMessage() {} -func (x *SQLQueryResponse) ProtoReflect() protoreflect.Message { +func (x *SQLExecResponse) ProtoReflect() protoreflect.Message { mi := &file_sql_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -123,73 +117,116 @@ func (x *SQLQueryResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SQLQueryResponse.ProtoReflect.Descriptor instead. -func (*SQLQueryResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use SQLExecResponse.ProtoReflect.Descriptor instead. +func (*SQLExecResponse) Descriptor() ([]byte, []int) { return file_sql_proto_rawDescGZIP(), []int{1} } -func (x *SQLQueryResponse) GetStatus() *Status { +func (x *SQLExecResponse) GetStatus() *Status { if x != nil { return x.Status } return nil } -func (x *SQLQueryResponse) GetLastInsertId() int64 { +func (x *SQLExecResponse) GetLastInsertId() int64 { if x != nil { return x.LastInsertId } return 0 } -func (x *SQLQueryResponse) GetRowsAffected() int64 { +func (x *SQLExecResponse) GetRowsAffected() int64 { if x != nil { return x.RowsAffected } return 0 } -func (x *SQLQueryResponse) GetColumns() []string { - if x != nil { - return x.Columns +// SQLQuery is a structure used to create SQL queries to a SQL Database. +type SQLQuery struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Query is the SQL Query to be executed. This field should be a byte slice + // to avoid conflicts with JSON encoding. + Query []byte `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"` +} + +func (x *SQLQuery) Reset() { + *x = SQLQuery{} + if protoimpl.UnsafeEnabled { + mi := &file_sql_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return nil } -func (x *SQLQueryResponse) GetRows() []*Row { +func (x *SQLQuery) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SQLQuery) ProtoMessage() {} + +func (x *SQLQuery) ProtoReflect() protoreflect.Message { + mi := &file_sql_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SQLQuery.ProtoReflect.Descriptor instead. +func (*SQLQuery) Descriptor() ([]byte, []int) { + return file_sql_proto_rawDescGZIP(), []int{2} +} + +func (x *SQLQuery) GetQuery() []byte { if x != nil { - return x.Rows + return x.Query } return nil } -// Row is a structure used to represent a row in a SQL query response. -// The data field is a map of column names to column values. -type Row struct { +// SQLQueryResponse is a structure supplied as a response message to a SQL +// Database Query. +type SQLQueryResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Data map[string][]byte `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // Status is the human readable error message or success message for function + // execution. + Status *Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` + // Columns is a list of column names returned by the query. This field is + // only populated if the query was a select query. + Columns []string `protobuf:"bytes,4,rep,name=columns,proto3" json:"columns,omitempty"` + // Data is a JSON encoded byte slice of the data returned by the query. + Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` } -func (x *Row) Reset() { - *x = Row{} +func (x *SQLQueryResponse) Reset() { + *x = SQLQueryResponse{} if protoimpl.UnsafeEnabled { - mi := &file_sql_proto_msgTypes[2] + mi := &file_sql_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *Row) String() string { +func (x *SQLQueryResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Row) ProtoMessage() {} +func (*SQLQueryResponse) ProtoMessage() {} -func (x *Row) ProtoReflect() protoreflect.Message { - mi := &file_sql_proto_msgTypes[2] +func (x *SQLQueryResponse) ProtoReflect() protoreflect.Message { + mi := &file_sql_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -200,12 +237,26 @@ func (x *Row) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Row.ProtoReflect.Descriptor instead. -func (*Row) Descriptor() ([]byte, []int) { - return file_sql_proto_rawDescGZIP(), []int{2} +// Deprecated: Use SQLQueryResponse.ProtoReflect.Descriptor instead. +func (*SQLQueryResponse) Descriptor() ([]byte, []int) { + return file_sql_proto_rawDescGZIP(), []int{3} +} + +func (x *SQLQueryResponse) GetStatus() *Status { + if x != nil { + return x.Status + } + return nil +} + +func (x *SQLQueryResponse) GetColumns() []string { + if x != nil { + return x.Columns + } + return nil } -func (x *Row) GetData() map[string][]byte { +func (x *SQLQueryResponse) GetData() []byte { if x != nil { return x.Data } @@ -217,31 +268,29 @@ var File_sql_proto protoreflect.FileDescriptor var file_sql_proto_rawDesc = []byte{ 0x0a, 0x09, 0x73, 0x71, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x73, 0x71, 0x6c, 0x1a, 0x0c, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x20, 0x0a, 0x08, 0x53, 0x51, 0x4c, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x22, 0xc4, 0x01, 0x0a, 0x10, 0x53, 0x51, 0x4c, 0x51, - 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, - 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x69, 0x6e, 0x73, - 0x65, 0x72, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6c, 0x61, - 0x73, 0x74, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x6f, - 0x77, 0x73, 0x5f, 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x0c, 0x72, 0x6f, 0x77, 0x73, 0x41, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, - 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x23, 0x0a, 0x04, 0x72, 0x6f, 0x77, - 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, - 0x2e, 0x73, 0x71, 0x6c, 0x2e, 0x52, 0x6f, 0x77, 0x52, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x22, 0x6d, - 0x0a, 0x03, 0x52, 0x6f, 0x77, 0x12, 0x2d, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x73, 0x71, 0x6c, - 0x2e, 0x52, 0x6f, 0x77, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x1a, 0x37, 0x0a, 0x09, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, - 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x28, 0x5a, - 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x61, 0x72, 0x6d, - 0x61, 0x63, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, - 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1f, 0x0a, 0x07, 0x53, 0x51, 0x4c, 0x45, 0x78, 0x65, 0x63, + 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x22, 0x84, 0x01, 0x0a, 0x0f, 0x53, 0x51, 0x4c, 0x45, 0x78, + 0x65, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x61, 0x72, + 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x69, 0x6e, 0x73, 0x65, 0x72, + 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, + 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x6f, 0x77, 0x73, + 0x5f, 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x0c, 0x72, 0x6f, 0x77, 0x73, 0x41, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x22, 0x20, 0x0a, + 0x08, 0x53, 0x51, 0x4c, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, + 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x22, + 0x68, 0x0a, 0x10, 0x53, 0x51, 0x4c, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, + 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, + 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2d, 0x70, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -257,22 +306,21 @@ func file_sql_proto_rawDescGZIP() []byte { } var file_sql_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_sql_proto_goTypes = []interface{}{ - (*SQLQuery)(nil), // 0: tarmac.sql.SQLQuery - (*SQLQueryResponse)(nil), // 1: tarmac.sql.SQLQueryResponse - (*Row)(nil), // 2: tarmac.sql.Row - nil, // 3: tarmac.sql.Row.DataEntry +var file_sql_proto_goTypes = []any{ + (*SQLExec)(nil), // 0: tarmac.sql.SQLExec + (*SQLExecResponse)(nil), // 1: tarmac.sql.SQLExecResponse + (*SQLQuery)(nil), // 2: tarmac.sql.SQLQuery + (*SQLQueryResponse)(nil), // 3: tarmac.sql.SQLQueryResponse (*Status)(nil), // 4: tarmac.Status } var file_sql_proto_depIdxs = []int32{ - 4, // 0: tarmac.sql.SQLQueryResponse.status:type_name -> tarmac.Status - 2, // 1: tarmac.sql.SQLQueryResponse.rows:type_name -> tarmac.sql.Row - 3, // 2: tarmac.sql.Row.data:type_name -> tarmac.sql.Row.DataEntry - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 4, // 0: tarmac.sql.SQLExecResponse.status:type_name -> tarmac.Status + 4, // 1: tarmac.sql.SQLQueryResponse.status:type_name -> tarmac.Status + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_sql_proto_init() } @@ -282,8 +330,8 @@ func file_sql_proto_init() { } file_tarmac_proto_init() if !protoimpl.UnsafeEnabled { - file_sql_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SQLQuery); i { + file_sql_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*SQLExec); i { case 0: return &v.state case 1: @@ -294,8 +342,8 @@ func file_sql_proto_init() { return nil } } - file_sql_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SQLQueryResponse); i { + file_sql_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*SQLExecResponse); i { case 0: return &v.state case 1: @@ -306,8 +354,20 @@ func file_sql_proto_init() { return nil } } - file_sql_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Row); i { + file_sql_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*SQLQuery); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sql_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*SQLQueryResponse); i { case 0: return &v.state case 1: diff --git a/proto/sql_vtproto.pb.go b/proto/sql_vtproto.pb.go index c209a2f0..4a49f393 100644 --- a/proto/sql_vtproto.pb.go +++ b/proto/sql_vtproto.pb.go @@ -6,12 +6,11 @@ package proto import ( fmt "fmt" - io "io" - unsafe "unsafe" - protohelpers "github.com/planetscale/vtprotobuf/protohelpers" proto "google.golang.org/protobuf/proto" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + unsafe "unsafe" ) const ( @@ -21,11 +20,11 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -func (m *SQLQuery) CloneVT() *SQLQuery { +func (m *SQLExec) CloneVT() *SQLExec { if m == nil { - return (*SQLQuery)(nil) + return (*SQLExec)(nil) } - r := new(SQLQuery) + r := new(SQLExec) if rhs := m.Query; rhs != nil { tmpBytes := make([]byte, len(rhs)) copy(tmpBytes, rhs) @@ -38,29 +37,38 @@ func (m *SQLQuery) CloneVT() *SQLQuery { return r } -func (m *SQLQuery) CloneMessageVT() proto.Message { +func (m *SQLExec) CloneMessageVT() proto.Message { return m.CloneVT() } -func (m *SQLQueryResponse) CloneVT() *SQLQueryResponse { +func (m *SQLExecResponse) CloneVT() *SQLExecResponse { if m == nil { - return (*SQLQueryResponse)(nil) + return (*SQLExecResponse)(nil) } - r := new(SQLQueryResponse) + r := new(SQLExecResponse) r.Status = m.Status.CloneVT() r.LastInsertId = m.LastInsertId r.RowsAffected = m.RowsAffected - if rhs := m.Columns; rhs != nil { - tmpContainer := make([]string, len(rhs)) - copy(tmpContainer, rhs) - r.Columns = tmpContainer + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) } - if rhs := m.Rows; rhs != nil { - tmpContainer := make([]*Row, len(rhs)) - for k, v := range rhs { - tmpContainer[k] = v.CloneVT() - } - r.Rows = tmpContainer + return r +} + +func (m *SQLExecResponse) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *SQLQuery) CloneVT() *SQLQuery { + if m == nil { + return (*SQLQuery)(nil) + } + r := new(SQLQuery) + if rhs := m.Query; rhs != nil { + tmpBytes := make([]byte, len(rhs)) + copy(tmpBytes, rhs) + r.Query = tmpBytes } if len(m.unknownFields) > 0 { r.unknownFields = make([]byte, len(m.unknownFields)) @@ -69,23 +77,25 @@ func (m *SQLQueryResponse) CloneVT() *SQLQueryResponse { return r } -func (m *SQLQueryResponse) CloneMessageVT() proto.Message { +func (m *SQLQuery) CloneMessageVT() proto.Message { return m.CloneVT() } -func (m *Row) CloneVT() *Row { +func (m *SQLQueryResponse) CloneVT() *SQLQueryResponse { if m == nil { - return (*Row)(nil) + return (*SQLQueryResponse)(nil) + } + r := new(SQLQueryResponse) + r.Status = m.Status.CloneVT() + if rhs := m.Columns; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.Columns = tmpContainer } - r := new(Row) if rhs := m.Data; rhs != nil { - tmpContainer := make(map[string][]byte, len(rhs)) - for k, v := range rhs { - tmpBytes := make([]byte, len(v)) - copy(tmpBytes, v) - tmpContainer[k] = tmpBytes - } - r.Data = tmpContainer + tmpBytes := make([]byte, len(rhs)) + copy(tmpBytes, rhs) + r.Data = tmpBytes } if len(m.unknownFields) > 0 { r.unknownFields = make([]byte, len(m.unknownFields)) @@ -94,11 +104,11 @@ func (m *Row) CloneVT() *Row { return r } -func (m *Row) CloneMessageVT() proto.Message { +func (m *SQLQueryResponse) CloneMessageVT() proto.Message { return m.CloneVT() } -func (this *SQLQuery) EqualVT(that *SQLQuery) bool { +func (this *SQLExec) EqualVT(that *SQLExec) bool { if this == that { return true } else if this == nil || that == nil { @@ -110,14 +120,14 @@ func (this *SQLQuery) EqualVT(that *SQLQuery) bool { return string(this.unknownFields) == string(that.unknownFields) } -func (this *SQLQuery) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*SQLQuery) +func (this *SQLExec) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SQLExec) if !ok { return false } return this.EqualVT(that) } -func (this *SQLQueryResponse) EqualVT(that *SQLQueryResponse) bool { +func (this *SQLExecResponse) EqualVT(that *SQLExecResponse) bool { if this == that { return true } else if this == nil || that == nil { @@ -132,71 +142,67 @@ func (this *SQLQueryResponse) EqualVT(that *SQLQueryResponse) bool { if this.RowsAffected != that.RowsAffected { return false } - if len(this.Columns) != len(that.Columns) { + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SQLExecResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SQLExecResponse) + if !ok { return false } - for i, vx := range this.Columns { - vy := that.Columns[i] - if vx != vy { - return false - } - } - if len(this.Rows) != len(that.Rows) { + return this.EqualVT(that) +} +func (this *SQLQuery) EqualVT(that *SQLQuery) bool { + if this == that { + return true + } else if this == nil || that == nil { return false } - for i, vx := range this.Rows { - vy := that.Rows[i] - if p, q := vx, vy; p != q { - if p == nil { - p = &Row{} - } - if q == nil { - q = &Row{} - } - if !p.EqualVT(q) { - return false - } - } + if string(this.Query) != string(that.Query) { + return false } return string(this.unknownFields) == string(that.unknownFields) } -func (this *SQLQueryResponse) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*SQLQueryResponse) +func (this *SQLQuery) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SQLQuery) if !ok { return false } return this.EqualVT(that) } -func (this *Row) EqualVT(that *Row) bool { +func (this *SQLQueryResponse) EqualVT(that *SQLQueryResponse) bool { if this == that { return true } else if this == nil || that == nil { return false } - if len(this.Data) != len(that.Data) { + if !this.Status.EqualVT(that.Status) { return false } - for i, vx := range this.Data { - vy, ok := that.Data[i] - if !ok { - return false - } - if string(vx) != string(vy) { + if len(this.Columns) != len(that.Columns) { + return false + } + for i, vx := range this.Columns { + vy := that.Columns[i] + if vx != vy { return false } } + if string(this.Data) != string(that.Data) { + return false + } return string(this.unknownFields) == string(that.unknownFields) } -func (this *Row) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*Row) +func (this *SQLQueryResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SQLQueryResponse) if !ok { return false } return this.EqualVT(that) } -func (m *SQLQuery) MarshalVT() (dAtA []byte, err error) { +func (m *SQLExec) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -209,12 +215,12 @@ func (m *SQLQuery) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SQLQuery) MarshalToVT(dAtA []byte) (int, error) { +func (m *SQLExec) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *SQLQuery) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *SQLExec) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -236,7 +242,7 @@ func (m *SQLQuery) MarshalToSizedBufferVT(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SQLQueryResponse) MarshalVT() (dAtA []byte, err error) { +func (m *SQLExecResponse) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -249,12 +255,12 @@ func (m *SQLQueryResponse) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SQLQueryResponse) MarshalToVT(dAtA []byte) (int, error) { +func (m *SQLExecResponse) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *SQLQueryResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *SQLExecResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -266,27 +272,6 @@ func (m *SQLQueryResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } - if len(m.Rows) > 0 { - for iNdEx := len(m.Rows) - 1; iNdEx >= 0; iNdEx-- { - size, err := m.Rows[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0x2a - } - } - if len(m.Columns) > 0 { - for iNdEx := len(m.Columns) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Columns[iNdEx]) - copy(dAtA[i:], m.Columns[iNdEx]) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Columns[iNdEx]))) - i-- - dAtA[i] = 0x22 - } - } if m.RowsAffected != 0 { i = protohelpers.EncodeVarint(dAtA, i, uint64(m.RowsAffected)) i-- @@ -310,7 +295,7 @@ func (m *SQLQueryResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Row) MarshalVT() (dAtA []byte, err error) { +func (m *SQLQuery) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -323,12 +308,52 @@ func (m *Row) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Row) MarshalToVT(dAtA []byte) (int, error) { +func (m *SQLQuery) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *Row) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *SQLQuery) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Query) > 0 { + i -= len(m.Query) + copy(dAtA[i:], m.Query) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Query))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SQLQueryResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SQLQueryResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SQLQueryResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -341,28 +366,35 @@ func (m *Row) MarshalToSizedBufferVT(dAtA []byte) (int, error) { copy(dAtA[i:], m.unknownFields) } if len(m.Data) > 0 { - for k := range m.Data { - v := m.Data[k] - baseI := i - i -= len(v) - copy(dAtA[i:], v) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) - i-- - dAtA[i] = 0x12 - i -= len(k) - copy(dAtA[i:], k) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x2a + } + if len(m.Columns) > 0 { + for iNdEx := len(m.Columns) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Columns[iNdEx]) + copy(dAtA[i:], m.Columns[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Columns[iNdEx]))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x22 } } + if m.Status != nil { + size, err := m.Status.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } -func (m *SQLQuery) MarshalVTStrict() (dAtA []byte, err error) { +func (m *SQLExec) MarshalVTStrict() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -375,12 +407,12 @@ func (m *SQLQuery) MarshalVTStrict() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SQLQuery) MarshalToVTStrict(dAtA []byte) (int, error) { +func (m *SQLExec) MarshalToVTStrict(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVTStrict(dAtA[:size]) } -func (m *SQLQuery) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { +func (m *SQLExec) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -402,7 +434,7 @@ func (m *SQLQuery) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SQLQueryResponse) MarshalVTStrict() (dAtA []byte, err error) { +func (m *SQLExecResponse) MarshalVTStrict() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -415,12 +447,12 @@ func (m *SQLQueryResponse) MarshalVTStrict() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SQLQueryResponse) MarshalToVTStrict(dAtA []byte) (int, error) { +func (m *SQLExecResponse) MarshalToVTStrict(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVTStrict(dAtA[:size]) } -func (m *SQLQueryResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { +func (m *SQLExecResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -432,27 +464,6 @@ func (m *SQLQueryResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } - if len(m.Rows) > 0 { - for iNdEx := len(m.Rows) - 1; iNdEx >= 0; iNdEx-- { - size, err := m.Rows[iNdEx].MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0x2a - } - } - if len(m.Columns) > 0 { - for iNdEx := len(m.Columns) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Columns[iNdEx]) - copy(dAtA[i:], m.Columns[iNdEx]) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Columns[iNdEx]))) - i-- - dAtA[i] = 0x22 - } - } if m.RowsAffected != 0 { i = protohelpers.EncodeVarint(dAtA, i, uint64(m.RowsAffected)) i-- @@ -476,7 +487,7 @@ func (m *SQLQueryResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *Row) MarshalVTStrict() (dAtA []byte, err error) { +func (m *SQLQuery) MarshalVTStrict() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -489,12 +500,52 @@ func (m *Row) MarshalVTStrict() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Row) MarshalToVTStrict(dAtA []byte) (int, error) { +func (m *SQLQuery) MarshalToVTStrict(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVTStrict(dAtA[:size]) } -func (m *Row) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { +func (m *SQLQuery) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Query) > 0 { + i -= len(m.Query) + copy(dAtA[i:], m.Query) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Query))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SQLQueryResponse) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SQLQueryResponse) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *SQLQueryResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -507,28 +558,35 @@ func (m *Row) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { copy(dAtA[i:], m.unknownFields) } if len(m.Data) > 0 { - for k := range m.Data { - v := m.Data[k] - baseI := i - i -= len(v) - copy(dAtA[i:], v) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) - i-- - dAtA[i] = 0x12 - i -= len(k) - copy(dAtA[i:], k) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x2a + } + if len(m.Columns) > 0 { + for iNdEx := len(m.Columns) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Columns[iNdEx]) + copy(dAtA[i:], m.Columns[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Columns[iNdEx]))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x22 + } + } + if m.Status != nil { + size, err := m.Status.MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *SQLQuery) SizeVT() (n int) { +func (m *SQLExec) SizeVT() (n int) { if m == nil { return 0 } @@ -542,7 +600,7 @@ func (m *SQLQuery) SizeVT() (n int) { return n } -func (m *SQLQueryResponse) SizeVT() (n int) { +func (m *SQLExecResponse) SizeVT() (n int) { if m == nil { return 0 } @@ -558,42 +616,49 @@ func (m *SQLQueryResponse) SizeVT() (n int) { if m.RowsAffected != 0 { n += 1 + protohelpers.SizeOfVarint(uint64(m.RowsAffected)) } - if len(m.Columns) > 0 { - for _, s := range m.Columns { - l = len(s) - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } + n += len(m.unknownFields) + return n +} + +func (m *SQLQuery) SizeVT() (n int) { + if m == nil { + return 0 } - if len(m.Rows) > 0 { - for _, e := range m.Rows { - l = e.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } + var l int + _ = l + l = len(m.Query) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } n += len(m.unknownFields) return n } -func (m *Row) SizeVT() (n int) { +func (m *SQLQueryResponse) SizeVT() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Data) > 0 { - for k, v := range m.Data { - _ = k - _ = v - l = 1 + len(v) + protohelpers.SizeOfVarint(uint64(len(v))) - mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + l - n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + if m.Status != nil { + l = m.Status.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.Columns) > 0 { + for _, s := range m.Columns { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } } + l = len(m.Data) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } n += len(m.unknownFields) return n } -func (m *SQLQuery) UnmarshalVT(dAtA []byte) error { +func (m *SQLExec) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -616,10 +681,10 @@ func (m *SQLQuery) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SQLQuery: wiretype end group for non-group") + return fmt.Errorf("proto: SQLExec: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SQLQuery: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SQLExec: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -678,7 +743,7 @@ func (m *SQLQuery) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *SQLQueryResponse) UnmarshalVT(dAtA []byte) error { +func (m *SQLExecResponse) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -701,10 +766,10 @@ func (m *SQLQueryResponse) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SQLQueryResponse: wiretype end group for non-group") + return fmt.Errorf("proto: SQLExecResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SQLQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SQLExecResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -781,43 +846,62 @@ func (m *SQLQueryResponse) UnmarshalVT(dAtA []byte) error { break } } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Columns", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err } - intStringLen := int(stringLen) - if intStringLen < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return protohelpers.ErrInvalidLength } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF } - if postIndex > l { + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SQLQuery) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { return io.ErrUnexpectedEOF } - m.Columns = append(m.Columns, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 5: + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SQLQuery: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SQLQuery: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Rows", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protohelpers.ErrIntOverflow @@ -827,24 +911,24 @@ func (m *SQLQueryResponse) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return protohelpers.ErrInvalidLength } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return protohelpers.ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Rows = append(m.Rows, &Row{}) - if err := m.Rows[len(m.Rows)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Query = append(m.Query[:0], dAtA[iNdEx:postIndex]...) + if m.Query == nil { + m.Query = []byte{} } iNdEx = postIndex default: @@ -869,7 +953,7 @@ func (m *SQLQueryResponse) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *Row) UnmarshalVT(dAtA []byte) error { +func (m *SQLQueryResponse) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -892,15 +976,15 @@ func (m *Row) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Row: wiretype end group for non-group") + return fmt.Errorf("proto: SQLQueryResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Row: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SQLQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -927,104 +1011,78 @@ func (m *Row) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Data == nil { - m.Data = make(map[string][]byte) - } - var mapkey string - var mapvalue []byte - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + if m.Status == nil { + m.Status = &Status{} + } + if err := m.Status.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Columns", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Columns = append(m.Columns, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return protohelpers.ErrInvalidLength - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return protohelpers.ErrInvalidLength - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapbyteLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapbyteLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intMapbyteLen := int(mapbyteLen) - if intMapbyteLen < 0 { - return protohelpers.ErrInvalidLength - } - postbytesIndex := iNdEx + intMapbyteLen - if postbytesIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postbytesIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = make([]byte, mapbyteLen) - copy(mapvalue, dAtA[iNdEx:postbytesIndex]) - iNdEx = postbytesIndex - } else { - iNdEx = entryPreIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break } } - m.Data[mapkey] = mapvalue + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex @@ -1048,7 +1106,7 @@ func (m *Row) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *SQLQuery) UnmarshalVTUnsafe(dAtA []byte) error { +func (m *SQLExec) UnmarshalVTUnsafe(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1071,10 +1129,10 @@ func (m *SQLQuery) UnmarshalVTUnsafe(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SQLQuery: wiretype end group for non-group") + return fmt.Errorf("proto: SQLExec: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SQLQuery: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SQLExec: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1130,7 +1188,7 @@ func (m *SQLQuery) UnmarshalVTUnsafe(dAtA []byte) error { } return nil } -func (m *SQLQueryResponse) UnmarshalVTUnsafe(dAtA []byte) error { +func (m *SQLExecResponse) UnmarshalVTUnsafe(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1153,10 +1211,10 @@ func (m *SQLQueryResponse) UnmarshalVTUnsafe(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SQLQueryResponse: wiretype end group for non-group") + return fmt.Errorf("proto: SQLExecResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SQLQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SQLExecResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1233,47 +1291,62 @@ func (m *SQLQueryResponse) UnmarshalVTUnsafe(dAtA []byte) error { break } } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Columns", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err } - intStringLen := int(stringLen) - if intStringLen < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return protohelpers.ErrInvalidLength } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF } - if postIndex > l { + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SQLQuery) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { return io.ErrUnexpectedEOF } - var stringValue string - if intStringLen > 0 { - stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - m.Columns = append(m.Columns, stringValue) - iNdEx = postIndex - case 5: + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SQLQuery: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SQLQuery: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Rows", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protohelpers.ErrIntOverflow @@ -1283,25 +1356,22 @@ func (m *SQLQueryResponse) UnmarshalVTUnsafe(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return protohelpers.ErrInvalidLength } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return protohelpers.ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Rows = append(m.Rows, &Row{}) - if err := m.Rows[len(m.Rows)-1].UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Query = dAtA[iNdEx:postIndex] iNdEx = postIndex default: iNdEx = preIndex @@ -1325,7 +1395,7 @@ func (m *SQLQueryResponse) UnmarshalVTUnsafe(dAtA []byte) error { } return nil } -func (m *Row) UnmarshalVTUnsafe(dAtA []byte) error { +func (m *SQLQueryResponse) UnmarshalVTUnsafe(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1348,15 +1418,15 @@ func (m *Row) UnmarshalVTUnsafe(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Row: wiretype end group for non-group") + return fmt.Errorf("proto: SQLQueryResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Row: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SQLQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1383,107 +1453,79 @@ func (m *Row) UnmarshalVTUnsafe(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Data == nil { - m.Data = make(map[string][]byte) - } - var mapkey string - var mapvalue []byte - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + if m.Status == nil { + m.Status = &Status{} + } + if err := m.Status.UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Columns", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + } + m.Columns = append(m.Columns, stringValue) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return protohelpers.ErrInvalidLength - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return protohelpers.ErrInvalidLength - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - if intStringLenmapkey == 0 { - mapkey = "" - } else { - mapkey = unsafe.String(&dAtA[iNdEx], intStringLenmapkey) - } - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapbyteLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapbyteLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intMapbyteLen := int(mapbyteLen) - if intMapbyteLen < 0 { - return protohelpers.ErrInvalidLength - } - postbytesIndex := iNdEx + intMapbyteLen - if postbytesIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postbytesIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = dAtA[iNdEx:postbytesIndex] - iNdEx = postbytesIndex - } else { - iNdEx = entryPreIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break } } - m.Data[mapkey] = mapvalue + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = dAtA[iNdEx:postIndex] iNdEx = postIndex default: iNdEx = preIndex diff --git a/proto/tarmac.pb.go b/proto/tarmac.pb.go index 5d1818bd..aabbf866 100644 --- a/proto/tarmac.pb.go +++ b/proto/tarmac.pb.go @@ -1,17 +1,16 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v5.27.1 +// protoc-gen-go v1.34.2 +// protoc v5.27.3 // source: tarmac.proto package proto import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( @@ -113,7 +112,7 @@ func file_tarmac_proto_rawDescGZIP() []byte { } var file_tarmac_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_tarmac_proto_goTypes = []interface{}{ +var file_tarmac_proto_goTypes = []any{ (*Status)(nil), // 0: tarmac.Status } var file_tarmac_proto_depIdxs = []int32{ @@ -130,7 +129,7 @@ func file_tarmac_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_tarmac_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_tarmac_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Status); i { case 0: return &v.state diff --git a/proto/tarmac_vtproto.pb.go b/proto/tarmac_vtproto.pb.go index a9f99e24..4210f993 100644 --- a/proto/tarmac_vtproto.pb.go +++ b/proto/tarmac_vtproto.pb.go @@ -6,12 +6,11 @@ package proto import ( fmt "fmt" - io "io" - unsafe "unsafe" - protohelpers "github.com/planetscale/vtprotobuf/protohelpers" proto "google.golang.org/protobuf/proto" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + unsafe "unsafe" ) const ( From 966fee3a2159496f8c9e6d2f72cde2a0802f8a0d Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 18 Aug 2024 08:42:18 -0700 Subject: [PATCH 04/31] Working SQL Exec, kinda --- pkg/callbacks/sql/sql.go | 52 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/pkg/callbacks/sql/sql.go b/pkg/callbacks/sql/sql.go index 62139d9a..e68f57f4 100644 --- a/pkg/callbacks/sql/sql.go +++ b/pkg/callbacks/sql/sql.go @@ -56,6 +56,53 @@ func New(cfg Config) (*Database, error) { return db, nil } +// Exec will execute the supplied query against the supplied database. Error handling, processing results, and base64 encoding +// of data are all handled via this function. Note, this function expects the SQLExec type as input +// and will return a SQLExecResponse JSON. +func (db *Database) Exec(b []byte) ([]byte, error) { + msg := &proto.SQLExec{} + err := pb.Unmarshal(b, msg) + if err != nil { + return []byte(""), fmt.Errorf("unable to unmarshal database:exec request") + } + + r := &proto.SQLExecResponse{} + r.Status = &proto.Status{Code: 200, Status: "OK"} + + if len(msg.Query) < 1 { + r.Status.Code = 400 + r.Status.Status = "SQL Query must be defined" + } + + var results sql.Result + if r.Status.Code == 200 { + results, err = db.exec(msg.Query) + if err != nil { + r.Status.Code = 500 + r.Status.Status = fmt.Sprintf("Unable to execute query - %s", err) + } + } + + // Set Row Count + r.RowsAffected, err = results.RowsAffected() + if err != nil { + r.RowsAffected = 0 + } + + // Set Last Insert ID + r.LastInsertId, err = results.LastInsertId() + if err != nil { + r.LastInsertId = 0 + } + + rsp, err := pb.Marshal(r) + if err != nil { + return []byte(""), fmt.Errorf("unable to marshal database:exec response") + } + + return rsp, nil +} + // Query will execute the supplied query against the supplied database. Error handling, processing results, and base64 encoding // of data are all handled via this function. Note, this function expects the SQLQueryJSON type as input // and will return a SQLQueryResponse JSON. @@ -161,7 +208,7 @@ func (db *Database) queryJSON(b []byte) ([]byte, error) { return rsp, fmt.Errorf("%s", r.Status.Status) } -// Query will execute the supplied query against the database and return +// query will execute the supplied query against the database and return // the rows as a list of maps. The keys in the map are the column names // and the values are the column values. func (db *Database) query(qry []byte) ([]string, []map[string]any, error) { @@ -206,6 +253,7 @@ func (db *Database) query(qry []byte) ([]string, []map[string]any, error) { return columns, results, nil } +// exec will execute the supplied query against the database and return the result. func (db *Database) exec(qry []byte) (sql.Result, error) { - return nil, fmt.Errorf("not implemented") + return db.db.Exec(fmt.Sprintf("%s", qry)) } From 37b5632c66519e64b2c4f1014609fafd99a7103c Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 25 Aug 2024 18:00:25 -0700 Subject: [PATCH 05/31] Working SQL callback --- pkg/callbacks/sql/sql.go | 38 +++++++++++++++++++++++++---------- pkg/callbacks/sql/sql_test.go | 18 ++++++++++------- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/pkg/callbacks/sql/sql.go b/pkg/callbacks/sql/sql.go index e68f57f4..c50e9e14 100644 --- a/pkg/callbacks/sql/sql.go +++ b/pkg/callbacks/sql/sql.go @@ -83,16 +83,24 @@ func (db *Database) Exec(b []byte) ([]byte, error) { } } - // Set Row Count - r.RowsAffected, err = results.RowsAffected() - if err != nil { - r.RowsAffected = 0 - } + if r.Status.Code == 200 { + // Set Row Count + ra, err := results.RowsAffected() + if err != nil { + r.Status.Code = 206 + r.Status.Status = fmt.Sprintf("Unable to get rows affected - %s", err) + r.RowsAffected = 0 + } + r.RowsAffected = ra - // Set Last Insert ID - r.LastInsertId, err = results.LastInsertId() - if err != nil { - r.LastInsertId = 0 + // Set Last Insert ID + id, err := results.LastInsertId() + if err != nil { + r.Status.Code = 206 + r.Status.Status = fmt.Sprintf("Unable to get last insert ID - %s", err) + r.LastInsertId = 0 + } + r.LastInsertId = id } rsp, err := pb.Marshal(r) @@ -100,7 +108,11 @@ func (db *Database) Exec(b []byte) ([]byte, error) { return []byte(""), fmt.Errorf("unable to marshal database:exec response") } - return rsp, nil + if r.Status.Code == 200 { + return rsp, nil + } + + return rsp, fmt.Errorf("%s", r.Status.Status) } // Query will execute the supplied query against the supplied database. Error handling, processing results, and base64 encoding @@ -148,7 +160,11 @@ func (db *Database) Query(b []byte) ([]byte, error) { return []byte(""), fmt.Errorf("unable to marshal database:query response") } - return rsp, nil + if r.Status.Code == 200 { + return rsp, nil + } + + return rsp, fmt.Errorf("%s", r.Status.Status) } // queryJSON retains the JSON interface for backwards compatibility with the Tarmac Host Callback interface. diff --git a/pkg/callbacks/sql/sql_test.go b/pkg/callbacks/sql/sql_test.go index ab129760..63ba57a3 100644 --- a/pkg/callbacks/sql/sql_test.go +++ b/pkg/callbacks/sql/sql_test.go @@ -98,7 +98,7 @@ func TestSQLQuery(t *testing.T) { t.Run("Happy Path", func(t *testing.T) { t.Run("Create Table", func(t *testing.T) { - query := &proto.SQLExec{Query: []byte(`CREATE TABLE IF NOT EXISTS testpkg ( id int NOT NULL, name varchar(255), PRIMARY KEY (id) );`)} + query := &proto.SQLExec{Query: []byte(`CREATE TABLE IF NOT EXISTS testpkg ( id int NOT NULL AUTO_INCREMENT, name varchar(255), PRIMARY KEY (id) );`)} qMsg, err := pb.Marshal(query) if err != nil { t.Fatalf("Unable to marshal query message") @@ -123,13 +123,13 @@ func TestSQLQuery(t *testing.T) { }) t.Run("Insert Data", func(t *testing.T) { - query := &proto.SQLExec{Query: []byte(`INSERT INTO testpkg (id, name) VALUES (1, "John Smith");`)} + query := &proto.SQLExec{Query: []byte(`INSERT INTO testpkg (name) VALUES ("John Smith");`)} qMsg, err := pb.Marshal(query) if err != nil { t.Fatalf("Unable to marshal query message") } - r, err := db.Query(qMsg) + r, err := db.Exec(qMsg) if err != nil { t.Errorf("Unable to execute table creation query - %s", err) } @@ -148,14 +148,13 @@ func TestSQLQuery(t *testing.T) { // Check Rows Affected if rsp.RowsAffected != 1 { - t.Fatalf("Unexpected rows affected - %d", rsp.RowsAffected) + t.Errorf("Unexpected rows affected - %d", rsp.RowsAffected) } // Check Last Insert ID if rsp.LastInsertId != 1 { - t.Fatalf("Unexpected last insert ID - %d", rsp.LastInsertId) + t.Errorf("Unexpected last insert ID - %d", rsp.LastInsertId) } - }) t.Run("Select Data", func(t *testing.T) { @@ -183,10 +182,15 @@ func TestSQLQuery(t *testing.T) { } // Verify Columns - if len(rsp.Columns) != 1 { + if len(rsp.Columns) != 2 { t.Fatalf("Unexpected number of columns returned - %d", len(rsp.Columns)) } + // Check Column Names + if rsp.Columns[0] != "id" && rsp.Columns[1] != "name" { + t.Fatalf("Unexpected column names returned - %v", rsp.Columns) + } + // Verify Data if len(rsp.Data) == 0 { t.Fatalf("No data returned from query") From 273eae9631c3de5b1754cf8cf3109a3460aedd35 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sat, 31 Aug 2024 12:18:29 -0700 Subject: [PATCH 06/31] Working KVStore callback with protobuf --- pkg/callbacks/kvstore/kvstore.go | 185 +++++++++++++- pkg/callbacks/kvstore/kvstore_test.go | 350 +++++++++++++++++++++++++- 2 files changed, 510 insertions(+), 25 deletions(-) diff --git a/pkg/callbacks/kvstore/kvstore.go b/pkg/callbacks/kvstore/kvstore.go index 31bb38da..844d6499 100644 --- a/pkg/callbacks/kvstore/kvstore.go +++ b/pkg/callbacks/kvstore/kvstore.go @@ -26,6 +26,9 @@ import ( "github.com/pquerna/ffjson/ffjson" "github.com/tarmac-project/hord" "github.com/tarmac-project/tarmac" + + "github.com/tarmac-project/tarmac/proto" + pb "google.golang.org/protobuf/proto" ) // KVStore provides access to Host Callbacks that interact with the key:value datastores within Tarmac. The callbacks @@ -47,6 +50,11 @@ type Config struct { KV hord.Database } +var ( + // ErrNilKey is returned when the key is nil + ErrNilKey = fmt.Errorf("key cannot be nil") +) + // New will create and return a new KVStore instance that users can register as a Tarmac Host Callback function. Users // can provide any custom KVStore configurations using the configuration options supplied. func New(cfg Config) (*KVStore, error) { @@ -58,10 +66,51 @@ func New(cfg Config) (*KVStore, error) { return k, nil } -// Get will fetch the stored data using the key specified within the incoming JSON. Logging, error handling, and -// base64 encoding of data are all handled via this function. Note, this function expects the KVStoreGetRequest -// JSON type as input and will return a KVStoreGetResponse JSON. +// Get will fetch data from the key:value datastore using the key specified. func (k *KVStore) Get(b []byte) ([]byte, error) { + msg := &proto.KVStoreGet{} + err := pb.Unmarshal(b, msg) + if err != nil { + return k.getJSON(b) + } + + rsp := &proto.KVStoreGetResponse{ + Status: &proto.Status{ + Code: 200, + Status: "OK", + }, + } + + if msg.Key == "" { + rsp.Status.Code = 400 + rsp.Status.Status = ErrNilKey.Error() + } + + if rsp.Status.Code == 200 { + data, err := k.kv.Get(msg.Key) + if err != nil { + rsp.Status.Code = 404 + rsp.Status.Status = fmt.Sprintf("Unable to fetch key %s", err) + } + + rsp.Data = data + } + + m, err = pb.Marshal(rsp) + if err != nil { + return nil, fmt.Errorf("unable to marshal kvstore:get response") + } + + if rsp.Status.Code == 200 { + return m, nil + } + + return m, fmt.Errorf("%s", rsp.Status.Status) +} + +// getJSON retains the JSON based Get function for backwards compatibility. This function will be removed in future +// versions of Tarmac. +func (k *KVStore) getJSON(b []byte) ([]byte, error) { // Start Response Message assuming everything is good r := tarmac.KVStoreGetResponse{} r.Status.Code = 200 @@ -99,10 +148,54 @@ func (k *KVStore) Get(b []byte) ([]byte, error) { return rsp, fmt.Errorf("%s", r.Status.Status) } -// Set will store data within the key:value datastore using the key specified within the incoming JSON. Logging, error -// handling, and base64 decoding of data are all handled via this function. Note, this function expects the -// KVStoreSetRequest JSON type as input and will return a KVStoreSetResponse JSON. +// Set will store data within the key:value datastore using the key specified. func (k *KVStore) Set(b []byte) ([]byte, error) { + msg := &proto.KVStoreSet{} + err := pb.Unmarshal(b, msg) + if err != nil { + return k.setJSON(b) + } + + rsp := &proto.KVStoreSetResponse{ + Status: &proto.Status{ + Code: 200, + Status: "OK", + }, + } + + if msg.Key == "" { + rsp.Status.Code = 400 + rsp.Status.Status = ErrNilKey.Error() + } + + if msg.Data == nil { + rsp.Status.Code = 400 + rsp.Status.Status = "Data cannot be nil" + } + + if rsp.Status.Code == 200 { + err = k.kv.Set(msg.Key, msg.Data) + if err != nil { + rsp.Status.Code = 500 + rsp.Status.Status = fmt.Sprintf("Unable to store data - %s", err) + } + } + + m, err = pb.Marshal(rsp) + if err != nil { + return nil, fmt.Errorf("unable to marshal kvstore:set response") + } + + if rsp.Status.Code == 200 { + return m, nil + } + + return m, fmt.Errorf("%s", rsp.Status.Status) +} + +// setJSON retains the JSON based Set function for backwards compatibility. This function will be removed in future +// versions of Tarmac. +func (k *KVStore) setJSON(b []byte) ([]byte, error) { // Start Response Message assuming everything is good r := tarmac.KVStoreSetResponse{} r.Status.Code = 200 @@ -144,10 +237,49 @@ func (k *KVStore) Set(b []byte) ([]byte, error) { return rsp, fmt.Errorf("%s", r.Status.Status) } -// Delete will remove the key and data stored within the key:value datastore using the key specified within the incoming -// JSON. Logging and error handling are all handled via this callback function. Note, this function expects the -// KVStoreDeleteRequest JSON type as input and will return a KVStoreDeleteResponse JSON. +// Delete will remove data from the key:value datastore using the key specified. func (k *KVStore) Delete(b []byte) ([]byte, error) { + msg := &proto.KVStoreDelete{} + err := pb.Unmarshal(b, msg) + if err != nil { + return k.deleteJSON(b) + } + + rsp := &proto.KVStoreDeleteResponse{ + Status: &proto.Status{ + Code: 200, + Status: "OK", + }, + } + + if msg.Key == "" { + rsp.Status.Code = 400 + rsp.Status.Status = ErrNilKey.Error() + } + + if rsp.Status.Code == 200 { + err = k.kv.Delete(msg.Key) + if err != nil { + rsp.Status.Code = 404 + rsp.Status.Status = fmt.Sprintf("Unable to delete key %s", err) + } + } + + m, err = pb.Marshal(rsp) + if err != nil { + return nil, fmt.Errorf("unable to marshal kvstore:delete response") + } + + if rsp.Status.Code == 200 { + return m, nil + } + + return m, fmt.Errorf("%s", rsp.Status.Status) +} + +// deleteJSON retains the JSON based Delete function for backwards compatibility. This function will be removed in future +// versions of Tarmac. +func (k *KVStore) deleteJSON(b []byte) ([]byte, error) { // Start Response Message assuming everything is good r := tarmac.KVStoreDeleteResponse{} r.Status.Code = 200 @@ -182,9 +314,38 @@ func (k *KVStore) Delete(b []byte) ([]byte, error) { return rsp, fmt.Errorf("%s", r.Status.Status) } -// Keys will return a list of all keys stored within the key:value datastore. Logging and error handling are -// all handled via this callback function. Note, this function will return a KVStoreKeysResponse JSON. -func (k *KVStore) Keys([]byte) ([]byte, error) { +func (k *KVStore) Keys(b []byte) ([]byte, error) { + if len(b) > 0 { + return k.keysJSON(b) + } + + rsp := &proto.KVStoreKeysResponse{ + Status: &proto.Status{ + Code: 200, + Status: "OK", + }, + } + + keys, err := k.kv.Keys() + if err != nil { + rsp.Status.Code = 500 + rsp.Status.Status = fmt.Sprintf("Unable to fetch keys - %s", err) + } + rsp.Keys = keys + + m, err := pb.Marshal(rsp) + if err != nil { + return nil, fmt.Errorf("unable to marshal kvstore:keys response") + } + + if rsp.Status.Code == 200 { + return m, nil + } + + return m, fmt.Errorf("%s", rsp.Status.Status) +} + +func (k *KVStore) keysJSON(b []byte) ([]byte, error) { // Start Response Message assuming everything is good r := tarmac.KVStoreKeysResponse{} r.Status.Code = 200 diff --git a/pkg/callbacks/kvstore/kvstore_test.go b/pkg/callbacks/kvstore/kvstore_test.go index ce809f50..75cf3688 100644 --- a/pkg/callbacks/kvstore/kvstore_test.go +++ b/pkg/callbacks/kvstore/kvstore_test.go @@ -1,15 +1,339 @@ package kvstore import ( + "bytes" "fmt" "testing" "github.com/pquerna/ffjson/ffjson" "github.com/tarmac-project/hord/drivers/mock" "github.com/tarmac-project/tarmac" + + "github.com/tarmac-project/tarmac/proto" + pb "google.golang.org/protobuf/proto" ) type KVStoreCase struct { + err bool + pass bool + name string + key string + value []byte + mockCfg mock.Config +} + +func TestKVStore(t *testing.T) { + td := map[string][]byte{ + "Happy Path Value": []byte("somedata"), + "Integer Value": {0x00, 0x00, 0x00, 0x64}, + "String Value": []byte("Hello, World!"), + "Float Value": {0x40, 0x49, 0x0f, 0xdb}, + "Boolean Value": {0x01}, + "JSON Object": []byte(`{"name":"Test","age":30}`), + "Binary Data": {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}, + "Special Characters in String": []byte("!@#$%^&*()_+"), + } + + t.Run("Get", func(t *testing.T) { + // Predefined test cases + kc := []KVStoreCase{ + { + err: true, + pass: false, + name: "Key not found", + key: "", + value: []byte(""), + mockCfg: mock.Config{ + GetFunc: func(key string) ([]byte, error) { + return nil, fmt.Errorf("Key not found") + }, + }, + }, + } + + // Dynamically generate test cases from the td map + for k, v := range td { + kc = append(kc, KVStoreCase{ + err: false, + pass: true, + name: k, + key: k, + value: v, + mockCfg: mock.Config{ + GetFunc: func(key string) ([]byte, error) { + if key == k { + return v, nil + } + return nil, fmt.Errorf("Key not found") + }, + }, + }) + } + + // Execute each test case + for _, c := range kc { + t.Run(c.name, func(t *testing.T) { + kv, _ := mock.Dial(c.mockCfg) + store, err := New(Config{KV: kv}) + if err != nil { + t.Fatalf("Failed to create KVStore instance: %v", err) + } + + req := &proto.KVStoreGet{Key: c.key} + b, err := pb.Marshal(req) + if err != nil { + t.Fatalf("Failed to marshal request: %v", err) + } + + rsp, err := store.Get(b) + if (err != nil) != c.err { + t.Fatalf("Unexpected error state: %v", err) + } + + var response proto.KVStoreGetResponse + if err := pb.Unmarshal(rsp, &response); err != nil { + t.Fatalf("Failed to unmarshal response: %v", err) + } + + if (response.Status.Code == 200) != c.pass { + t.Fatalf("Unexpected response status: %+v", response) + } + + if c.pass && !bytes.Equal(response.Data, c.value) { + t.Fatalf("Unexpected response data: %+v", response) + } + }) + } + }) + + t.Run("Set", func(t *testing.T) { + // Predefined test cases + kc := []KVStoreCase{ + { + err: true, + pass: false, + name: "No Data", + key: "no-data", + value: []byte(""), + mockCfg: mock.Config{ + SetFunc: func(key string, data []byte) error { + return nil + }, + }, + }, + { + err: true, + pass: false, + name: "No Key", + key: "", + value: []byte("some data"), + mockCfg: mock.Config{ + SetFunc: func(key string, data []byte) error { + return nil + }, + }, + }, + } + + // Dynamically generate test cases from the td map + for k, v := range td { + kc = append(kc, KVStoreCase{ + err: false, + pass: true, + name: k, + key: k, + value: v, + mockCfg: mock.Config{ + SetFunc: func(key string, data []byte) error { + if key == k && bytes.Equal(data, v) { + return nil + } + return fmt.Errorf("Error inserting data") + }, + }, + }) + } + + // Execute each test case + for _, c := range kc { + t.Run(c.name, func(t *testing.T) { + kv, _ := mock.Dial(c.mockCfg) + k, err := New(Config{KV: kv}) + if err != nil { + t.Fatalf("Failed to create KVStore instance: %v", err) + } + + req := &proto.KVStoreSet{Key: c.key, Data: c.value} + b, err := pb.Marshal(req) + if err != nil { + t.Fatalf("Failed to marshal request: %v", err) + } + + rsp, err := k.Set(b) + if (err != nil) != c.err { + t.Fatalf("Unexpected error state: %v", err) + } + + var response proto.KVStoreSetResponse + if err := pb.Unmarshal(rsp, &response); err != nil { + t.Fatalf("Failed to unmarshal response: %v", err) + } + + if (response.Status.Code == 200) != c.pass { + t.Fatalf("Unexpected response status: %+v", response) + } + }) + } + }) + + t.Run("Delete", func(t *testing.T) { + // Predefined test cases + kc := []KVStoreCase{ + { + err: true, + pass: false, + name: "Key not found", + key: "", + value: []byte(""), + mockCfg: mock.Config{ + DeleteFunc: func(key string) error { + return nil + }, + }, + }, + { + err: false, + pass: true, + name: "Happy Path", + key: "testing-happy", + mockCfg: mock.Config{ + DeleteFunc: func(key string) error { + if key == "testing-happy" { + return nil + } + return fmt.Errorf("Key not found") + }, + }, + }, + } + + // Execute each test case + for _, c := range kc { + t.Run(c.name, func(t *testing.T) { + kv, _ := mock.Dial(c.mockCfg) + k, err := New(Config{KV: kv}) + if err != nil { + t.Fatalf("Failed to create KVStore instance: %v", err) + } + + req := &proto.KVStoreDelete{Key: c.key} + b, err := pb.Marshal(req) + if err != nil { + t.Fatalf("Failed to marshal request: %v", err) + } + + rsp, err := k.Delete(b) + if (err != nil) != c.err { + t.Fatalf("Unexpected error state: %v", err) + } + + var response proto.KVStoreDeleteResponse + if err := pb.Unmarshal(rsp, &response); err != nil { + t.Fatalf("Failed to unmarshal response: %v", err) + } + + if (response.Status.Code == 200) != c.pass { + t.Fatalf("Unexpected response status: %+v", response) + } + }) + } + }) + + t.Run("Keys", func(t *testing.T) { + // Predefined test cases + kc := []KVStoreCase{ + { + err: true, + pass: false, + name: "Errored Keys", + key: "", + value: []byte(""), + mockCfg: mock.Config{ + KeysFunc: func() ([]string, error) { + return []string{}, fmt.Errorf("Forced Error") + }, + }, + }, + { + err: false, + pass: true, + name: "Happy Path", + key: "", + value: []byte(""), + mockCfg: mock.Config{ + KeysFunc: func() ([]string, error) { + return []string{"key1", "key2", "key3"}, nil + }, + }, + }, + { + err: false, + pass: true, + name: "Sooo Many Keys", + key: "", + value: []byte(""), + mockCfg: mock.Config{ + KeysFunc: func() ([]string, error) { + keys := make([]string, 100) + for i := 0; i < 100; i++ { + keys[i] = fmt.Sprintf("key%d", i) + } + return keys, nil + }, + }, + }, + { + err: false, + pass: true, + name: "No Keys", + key: "", + value: []byte(""), + mockCfg: mock.Config{ + KeysFunc: func() ([]string, error) { + return []string{}, nil + }, + }, + }, + } + + // Execute each test case + for _, c := range kc { + t.Run(c.name, func(t *testing.T) { + kv, _ := mock.Dial(c.mockCfg) + k, err := New(Config{KV: kv}) + if err != nil { + t.Fatalf("Failed to create KVStore instance: %v", err) + } + + rsp, err := k.Keys([]byte{}) + if (err != nil) != c.err { + t.Fatalf("Unexpected error state: %v", err) + } + + var response proto.KVStoreKeysResponse + if err := pb.Unmarshal(rsp, &response); err != nil { + t.Fatalf("Failed to unmarshal response: %v", err) + } + + if (response.Status.Code == 200) != c.pass { + t.Fatalf("Unexpected response status: %+v", response) + } + }) + } + }) +} + +type KVStoreCaseJSON struct { err bool pass bool name string @@ -17,7 +341,7 @@ type KVStoreCase struct { json string } -func TestKVStore(t *testing.T) { +func TestKVStoreJSON(t *testing.T) { // Set DB as a Mocked Database kv, _ := mock.Dial(mock.Config{ GetFunc: func(key string) ([]byte, error) { @@ -50,10 +374,10 @@ func TestKVStore(t *testing.T) { t.Errorf("Unable to create new KVStore Instance - %s", err) } - var kc []KVStoreCase + var kc []KVStoreCaseJSON // Create a collection of test cases - kc = append(kc, KVStoreCase{ + kc = append(kc, KVStoreCaseJSON{ err: false, pass: true, name: "Happy Path", @@ -61,7 +385,7 @@ func TestKVStore(t *testing.T) { json: `{"key":"testing-happy"}`, }) - kc = append(kc, KVStoreCase{ + kc = append(kc, KVStoreCaseJSON{ err: false, pass: true, name: "Happy Path", @@ -69,7 +393,7 @@ func TestKVStore(t *testing.T) { json: `{"key":"testing-happy","data":"QmVjYXVzZSBJJ20gSGFwcHk="}`, }) - kc = append(kc, KVStoreCase{ + kc = append(kc, KVStoreCaseJSON{ err: false, pass: true, name: "Happy Path", @@ -77,7 +401,7 @@ func TestKVStore(t *testing.T) { json: `{"key":"testing-happy"}`, }) - kc = append(kc, KVStoreCase{ + kc = append(kc, KVStoreCaseJSON{ err: true, pass: false, name: "Invalid Request JSON", @@ -85,7 +409,7 @@ func TestKVStore(t *testing.T) { json: `{"ke:"testing-happy"}`, }) - kc = append(kc, KVStoreCase{ + kc = append(kc, KVStoreCaseJSON{ err: true, pass: false, name: "Invalid Request JSON", @@ -93,7 +417,7 @@ func TestKVStore(t *testing.T) { json: `{"ke:"testing-happy","data":"QmVjYXVzZSBJJ20gSGFwcHk="}`, }) - kc = append(kc, KVStoreCase{ + kc = append(kc, KVStoreCaseJSON{ err: true, pass: false, name: "Invalid Request JSON", @@ -101,7 +425,7 @@ func TestKVStore(t *testing.T) { json: `{"ke:"testing-happy"}`, }) - kc = append(kc, KVStoreCase{ + kc = append(kc, KVStoreCaseJSON{ err: true, pass: false, name: "Payload Not Base64", @@ -109,7 +433,7 @@ func TestKVStore(t *testing.T) { json: `{"key":"testing-happy","data":"not base64"}`, }) - kc = append(kc, KVStoreCase{ + kc = append(kc, KVStoreCaseJSON{ err: true, pass: false, name: "Key not found", @@ -117,7 +441,7 @@ func TestKVStore(t *testing.T) { json: `{"key":""}`, }) - kc = append(kc, KVStoreCase{ + kc = append(kc, KVStoreCaseJSON{ err: true, pass: false, name: "Failing Call", @@ -125,7 +449,7 @@ func TestKVStore(t *testing.T) { json: `{"key": "invalid-key"}`, }) - kc = append(kc, KVStoreCase{ + kc = append(kc, KVStoreCaseJSON{ err: true, pass: false, name: "No Data", @@ -133,7 +457,7 @@ func TestKVStore(t *testing.T) { json: `{"key":"no-data"}`, }) - kc = append(kc, KVStoreCase{ + kc = append(kc, KVStoreCaseJSON{ err: true, pass: false, name: "Errored Keys", From 3851f755d8cc431c499a1eab23aa2506d50d6be9 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 1 Sep 2024 07:44:03 -0700 Subject: [PATCH 07/31] Just a bit of cleanliness --- pkg/callbacks/kvstore/kvstore_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/callbacks/kvstore/kvstore_test.go b/pkg/callbacks/kvstore/kvstore_test.go index 75cf3688..3241a9ee 100644 --- a/pkg/callbacks/kvstore/kvstore_test.go +++ b/pkg/callbacks/kvstore/kvstore_test.go @@ -29,8 +29,8 @@ func TestKVStore(t *testing.T) { "String Value": []byte("Hello, World!"), "Float Value": {0x40, 0x49, 0x0f, 0xdb}, "Boolean Value": {0x01}, - "JSON Object": []byte(`{"name":"Test","age":30}`), - "Binary Data": {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}, + "JSON Object": []byte(`{"name":"Test","msg":"Hi!"}`), + "Binary Data": []byte{0x00, 0x01, 0x02, 0x03, 0x04}, "Special Characters in String": []byte("!@#$%^&*()_+"), } From 99fb43238206adb409c07dcd89649119b9a17830 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 1 Sep 2024 18:11:04 -0700 Subject: [PATCH 08/31] refactor(metrics-callback): Refectoring metrics callback --- pkg/callbacks/metrics/metrics.go | 128 ++++++---- pkg/callbacks/metrics/metrics_test.go | 345 ++++++++++++++++++++++---- 2 files changed, 384 insertions(+), 89 deletions(-) diff --git a/pkg/callbacks/metrics/metrics.go b/pkg/callbacks/metrics/metrics.go index 06af22fd..c21901d5 100644 --- a/pkg/callbacks/metrics/metrics.go +++ b/pkg/callbacks/metrics/metrics.go @@ -26,6 +26,9 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/tarmac-project/tarmac" + + "github.com/tarmac-project/tarmac/proto" + pb "google.golang.org/protobuf/proto" ) // Metrics stores and manages the user-defined metrics created via @@ -67,9 +70,17 @@ func New(_ Config) (*Metrics, error) { return m, nil } -// Counter will create and increment a counter metric. The expected input for -// this function is a MetricsCounter JSON. func (m *Metrics) Counter(b []byte) ([]byte, error) { + rq := &proto.MetricsCounter{} + err := pb.Unmarshal(b, rq) + if err != nil { + return m.jsonCounter(b) + } + + return []byte(""), m.counter(rq.Name) +} + +func (m *Metrics) jsonCounter(b []byte) ([]byte, error) { // Parse incoming Request var rq tarmac.MetricsCounter err := ffjson.Unmarshal(b, &rq) @@ -77,9 +88,13 @@ func (m *Metrics) Counter(b []byte) ([]byte, error) { return []byte(""), fmt.Errorf("unable to parse input JSON - %s", err) } + return []byte(""), m.counter(rq.Name) +} + +func (m *Metrics) counter(name string) error { // Verify Name Value - if !isMetricNameValid.MatchString(rq.Name) { - return []byte(""), ErrInvalidMetricName + if !isMetricNameValid.MatchString(name) { + return ErrInvalidMetricName } // Map Safety @@ -87,28 +102,37 @@ func (m *Metrics) Counter(b []byte) ([]byte, error) { defer m.Unlock() // Check if counter already exists, if not create one - _, ok := m.counters[rq.Name] + _, ok := m.counters[name] if !ok { // Check if name is already used - _, ok2 := m.all[rq.Name] + _, ok2 := m.all[name] if ok2 { - return []byte(""), fmt.Errorf("metric name in use") + return fmt.Errorf("metric name in use") } - m.counters[rq.Name] = promauto.NewCounter(prometheus.CounterOpts{ - Name: rq.Name, + m.counters[name] = promauto.NewCounter(prometheus.CounterOpts{ + Name: name, }) - m.all[rq.Name] = "counter" + m.all[name] = "counter" } // Perform action - m.counters[rq.Name].Inc() - return []byte(""), nil + m.counters[name].Inc() + return nil } -// Gauge will create a gauge metric and either increment or decrement the value -// based on the provided input. The expected input for this function is a -// MetricsGauge JSON. +// Gauge will create a gauge metric and perform the provided action. func (m *Metrics) Gauge(b []byte) ([]byte, error) { + // Parse incoming Request + rq := &proto.MetricsGauge{} + err := pb.Unmarshal(b, rq) + if err != nil { + return m.jsonGauge(b) + } + + return []byte(""), m.gauge(rq.Name, rq.Action) +} + +func (m *Metrics) jsonGauge(b []byte) ([]byte, error) { // Parse incoming Request var rq tarmac.MetricsGauge err := ffjson.Unmarshal(b, &rq) @@ -116,9 +140,17 @@ func (m *Metrics) Gauge(b []byte) ([]byte, error) { return []byte(""), fmt.Errorf("unable to parse input JSON - %s", err) } + return []byte(""), m.gauge(rq.Name, rq.Action) +} + +func (m *Metrics) gauge(name string, action string) error { // Verify Name Value - if !isMetricNameValid.MatchString(rq.Name) { - return []byte(""), ErrInvalidMetricName + if !isMetricNameValid.MatchString(name) { + return ErrInvalidMetricName + } + + if action != "inc" && action != "dec" { + return fmt.Errorf("invalid action") } // Map Safety @@ -126,36 +158,45 @@ func (m *Metrics) Gauge(b []byte) ([]byte, error) { defer m.Unlock() // Check if gauge already exists, if not create one - _, ok := m.gauges[rq.Name] + _, ok := m.gauges[name] if !ok { // Check if name is already used - _, ok2 := m.all[rq.Name] + _, ok2 := m.all[name] if ok2 { - return []byte(""), fmt.Errorf("metric name in use") + return fmt.Errorf("metric name in use") } - m.gauges[rq.Name] = promauto.NewGauge(prometheus.GaugeOpts{ - Name: rq.Name, + m.gauges[name] = promauto.NewGauge(prometheus.GaugeOpts{ + Name: name, }) - m.all[rq.Name] = "gauge" + m.all[name] = "gauge" } // Perform action - switch rq.Action { + switch action { case "inc": - m.gauges[rq.Name].Inc() + m.gauges[name].Inc() case "dec": - m.gauges[rq.Name].Dec() + m.gauges[name].Dec() default: - return []byte(""), fmt.Errorf("invalid action") + return fmt.Errorf("invalid action") } - return []byte(""), nil + return nil } -// Histogram will create a histogram or summary metric and observe the -// provided values. The expected input for this function is a -// MetricsHistogram JSON. +// Histogram will create a histogram metric and perform the provided action. func (m *Metrics) Histogram(b []byte) ([]byte, error) { + // Parse incoming Request + rq := &proto.MetricsHistogram{} + err := pb.Unmarshal(b, rq) + if err != nil { + return m.jsonHistogram(b) + } + + return []byte(""), m.histogram(rq.Name, rq.Value) +} + +func (m *Metrics) jsonHistogram(b []byte) ([]byte, error) { // Parse incoming Request var rq tarmac.MetricsHistogram err := ffjson.Unmarshal(b, &rq) @@ -163,9 +204,13 @@ func (m *Metrics) Histogram(b []byte) ([]byte, error) { return []byte(""), fmt.Errorf("unable to parse input JSON - %s", err) } + return []byte(""), m.histogram(rq.Name, rq.Value) +} + +func (m *Metrics) histogram(name string, value float64) error { // Verify Name Value - if !isMetricNameValid.MatchString(rq.Name) { - return []byte(""), ErrInvalidMetricName + if !isMetricNameValid.MatchString(name) { + return ErrInvalidMetricName } // Map Safety @@ -173,22 +218,21 @@ func (m *Metrics) Histogram(b []byte) ([]byte, error) { defer m.Unlock() // Check if histogram already exists, if not create one - _, ok := m.histograms[rq.Name] + _, ok := m.histograms[name] if !ok { // Check if name is already used - _, ok2 := m.all[rq.Name] + _, ok2 := m.all[name] if ok2 { - return []byte(""), fmt.Errorf("metric name in use") + return fmt.Errorf("metric name in use") } - m.histograms[rq.Name] = promauto.NewSummary(prometheus.SummaryOpts{ - Name: rq.Name, + m.histograms[name] = promauto.NewSummary(prometheus.SummaryOpts{ + Name: name, Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, }) - m.all[rq.Name] = "histogram" + m.all[name] = "histogram" } // Perform action - m.histograms[rq.Name].Observe(rq.Value) - - return []byte(""), nil + m.histograms[name].Observe(value) + return nil } diff --git a/pkg/callbacks/metrics/metrics_test.go b/pkg/callbacks/metrics/metrics_test.go index 1967250e..c99b925c 100644 --- a/pkg/callbacks/metrics/metrics_test.go +++ b/pkg/callbacks/metrics/metrics_test.go @@ -2,6 +2,9 @@ package metrics import ( "testing" + + "github.com/tarmac-project/tarmac/proto" + pb "google.golang.org/protobuf/proto" ) type MetricsCase struct { @@ -10,13 +13,261 @@ type MetricsCase struct { Exists bool Callback string Key string - JSON string + Action string + Value float64 } func TestMetricsCallback(t *testing.T) { - var tc []MetricsCase + tc := []MetricsCase{ + { + Name: "Empty Metric Name Counter", + Pass: false, + Exists: false, + Callback: "counter", + }, + { + Name: "Empty Metric Name Gauge", + Pass: false, + Exists: false, + Callback: "gauge", + }, + { + Name: "Empty Metric Name Histogram", + Pass: false, + Exists: false, + Callback: "histogram", + }, + { + Name: "Happy Path", + Pass: true, + Exists: true, + Callback: "counter", + Key: "happy_path", + }, + { + Name: "Happy Path - Inc", + Pass: true, + Exists: true, + Callback: "gauge", + Key: "happy_path_gauge", + Action: "inc", + }, + { + Name: "Happy Path - Dec", + Pass: true, + Exists: true, + Callback: "gauge", + Key: "happy_path_gauge", + Action: "dec", + }, + { + Name: "Happy Path - Histogram", + Pass: true, + Exists: true, + Callback: "histogram", + Key: "happy_path_histo", + Value: 0.11231, + }, + { + Name: "Weird Characters", + Pass: false, + Exists: false, + Callback: "counter", + Key: "aw3er2324re2309vcqASEDFAQSWWEqwrqwQ!@#$@#VQ", + }, + { + Name: "Weird Characters - Inc", + Pass: false, + Exists: false, + Callback: "gauge", + Key: "aw3er2324re2309vcqASEDFAQSWWEqwrqwQ!@#$@#VQ", + Action: "inc", + }, + { + Name: "Weird Characters - Dec", + Pass: false, + Exists: false, + Callback: "gauge", + Key: "aw3er2324re2309vcqASEDFAQSWWEqwrqwQ!@#$@#VQ", + Action: "dec", + }, + { + Name: "Weird Characters - Histogram", + Pass: false, + Exists: false, + Callback: "histogram", + Key: "aw3er2324re2309vcqASEDFAQSWWEqwrqwQ!@#$@#VQ", + Value: 0.11231, + }, + { + Name: "Invalid Action", + Pass: false, + Exists: false, + Callback: "gauge", + Key: "happy_path_gauge", + Action: "notvalid", + }, + { + Name: "Missing Action", + Pass: false, + Exists: false, + Callback: "gauge", + Key: "happy_path_gauge", + }, + { + Name: "Missing Value", + Pass: false, + Exists: false, + Callback: "histogram", + Key: "happy_path_histo", + }, + { + Name: "Additional Runs", + Pass: true, + Exists: true, + Callback: "counter", + Key: "happy_path", + }, + { + Name: "Additional Runs - Inc", + Pass: true, + Exists: true, + Callback: "gauge", + Key: "happy_path_gauge", + Action: "inc", + }, + { + Name: "Additional Runs - Dec", + Pass: true, + Exists: true, + Callback: "gauge", + Key: "happy_path_gauge", + Action: "dec", + }, + { + Name: "Additional Runs - Histogram", + Pass: true, + Exists: true, + Callback: "histogram", + Key: "happy_path_histo", + Value: 0.11231, + }, + { + Name: "Duplicate Name with different type - Counter", + Pass: false, + Exists: false, + Callback: "counter", + Key: "happy_path_histo", + }, + { + Name: "Duplicate Name with different type - Gauge", + Pass: false, + Exists: false, + Callback: "gauge", + Key: "happy_path", + Action: "inc", + }, + { + Name: "Duplicate Name with different type - Histogram", + Pass: false, + Exists: false, + Callback: "histogram", + Key: "happy_path_gauge", + Value: 0.11231, + }, + } + + statsCallback, err := New(Config{}) + if err != nil { + t.Fatalf("Unable to initialize new metrics - %s", err) + } + + for _, c := range tc { + t.Run(c.Name+" - "+c.Callback, func(t *testing.T) { + switch c.Callback { + case "counter": + msg := &proto.MetricsCounter{ + Name: c.Key, + } + b, err := pb.Marshal(msg) + if err != nil { + t.Fatalf("Unable to marshal message - %s", err) + } + + // Call Counter + _, err = statsCallback.Counter(b) + if err != nil && c.Pass { + t.Errorf("Unexpected error calling callback - %s", err) + } + + // Verify metric exists + _, ok := statsCallback.counters[c.Key] + if c.Exists && !ok { + t.Errorf("Metric not created") + } + case "gauge": + msg := &proto.MetricsGauge{ + Name: c.Key, + Action: c.Action, + } + b, err := pb.Marshal(msg) + if err != nil { + t.Fatalf("Unable to marshal message - %s", err) + } + + // Call Gauge + _, err = statsCallback.Gauge(b) + if err != nil && c.Pass { + t.Errorf("Unexpected error calling callback - %s", err) + } + + // Verify metric exists + _, ok := statsCallback.gauges[c.Key] + if c.Exists && !ok { + t.Errorf("Metric not created") + } + case "histogram": + msg := &proto.MetricsHistogram{ + Name: c.Key, + Value: c.Value, + } + b, err := pb.Marshal(msg) + if err != nil { + t.Fatalf("Unable to marshal message - %s", err) + } + + // Call Histogram + _, err = statsCallback.Histogram(b) + if err != nil && c.Pass { + t.Errorf("Unexpected error calling callback - %s", err) + } + + // Verify metric exists + _, ok := statsCallback.histograms[c.Key] + if c.Exists && !ok { + t.Errorf("Metric not created") + } + default: + t.Errorf("Unknown callback method - %s", c.Callback) + } + }) + + } +} + +type MetricsCaseJSON struct { + Name string + Pass bool + Exists bool + Callback string + Key string + JSON string +} + +func TestMetricsCallbackJSON(t *testing.T) { + var tc []MetricsCaseJSON - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Empty Metric Name", Pass: false, Callback: "counter", @@ -25,16 +276,16 @@ func TestMetricsCallback(t *testing.T) { JSON: `{"name":""}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Happy Path", Pass: true, Callback: "counter", Exists: true, - Key: "happy_path", - JSON: `{"name":"happy_path"}`, + Key: "json_happy_path", + JSON: `{"name":"json_happy_path"}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Weird Characters", Pass: false, Callback: "counter", @@ -43,16 +294,16 @@ func TestMetricsCallback(t *testing.T) { JSON: `{"name":"aw3er2324re2309vcqASEDFAQSWWEqwrqwQ!@#$@#VQ"}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Invalid JSON", Pass: false, Callback: "counter", Exists: false, - Key: "happy_path", - JSON: `{"name":"happy_path}`, + Key: "json_happy_path", + JSON: `{"name":"json_happy_path}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Empty Metric Name", Pass: false, Callback: "gauge", @@ -61,61 +312,61 @@ func TestMetricsCallback(t *testing.T) { JSON: `{"name":""}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Invalid JSON", Pass: false, Callback: "gauge", Exists: false, - Key: "happy_path", - JSON: `{"name":"happy_path}`, + Key: "json_happy_path", + JSON: `{"name":"json_happy_path}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Missing Action", Pass: false, Callback: "gauge", Exists: false, - Key: "happy_path", - JSON: `{"name":"happy_path"}`, + Key: "json_happy_path", + JSON: `{"name":"json_happy_path"}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Duplicate Name", Pass: false, Callback: "gauge", Exists: false, - Key: "happy_path", - JSON: `{"name":"happy_path","action":"inc"}`, + Key: "json_happy_path", + JSON: `{"name":"json_happy_path","action":"inc"}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Happy Path - Inc", Pass: true, Callback: "gauge", Exists: true, - Key: "happy_path_gauge", - JSON: `{"name":"happy_path_gauge","action":"inc"}`, + Key: "json_happy_path_gauge", + JSON: `{"name":"json_happy_path_gauge","action":"inc"}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Happy Path - Dec", Pass: true, Callback: "gauge", Exists: true, - Key: "happy_path_gauge", - JSON: `{"name":"happy_path_gauge","action":"dec"}`, + Key: "json_happy_path_gauge", + JSON: `{"name":"json_happy_path_gauge","action":"dec"}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Invalid Action", Pass: false, Callback: "gauge", Exists: false, - Key: "happy_path_gauge", - JSON: `{"name":"happy_path_gauge","action":"notvalid"}`, + Key: "json_happy_path_gauge", + JSON: `{"name":"json_happy_path_gauge","action":"notvalid"}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Weird Characters", Pass: false, Callback: "gauge", @@ -124,7 +375,7 @@ func TestMetricsCallback(t *testing.T) { JSON: `{"name":"aw3er2324re2309vcqASEDFAQSWWEqwrqwQ!@#$@#VQ"}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Empty Metric Name", Pass: false, Callback: "histogram", @@ -133,43 +384,43 @@ func TestMetricsCallback(t *testing.T) { JSON: `{"name":""}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Invalid JSON", Pass: false, Callback: "histogram", Exists: false, - Key: "happy_path", - JSON: `{"name":"happy_path}`, + Key: "json_happy_path", + JSON: `{"name":"json_happy_path}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Missing Value", Pass: false, Callback: "histogram", Exists: false, - Key: "happy_path_histo", - JSON: `{"name":"happy_path"}`, + Key: "json_happy_path_histo", + JSON: `{"name":"json_happy_path"}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Duplicate Name", Pass: false, Callback: "histogram", Exists: false, - Key: "happy_path", - JSON: `{"name":"happy_path","Value":0.11231}`, + Key: "json_happy_path", + JSON: `{"name":"json_happy_path","Value":0.11231}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Happy Path", Pass: true, Callback: "histogram", Exists: true, - Key: "happy_path_histo", - JSON: `{"name":"happy_path_histo","Value":0.11231}`, + Key: "json_happy_path_histo", + JSON: `{"name":"json_happy_path_histo","Value":0.11231}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Weird Characters", Pass: false, Callback: "histogram", @@ -178,13 +429,13 @@ func TestMetricsCallback(t *testing.T) { JSON: `{"name":"aw3er2324re2309vcqASEDFAQSWWEqwrqwQ!@#$@#VQ"}`, }) - tc = append(tc, MetricsCase{ + tc = append(tc, MetricsCaseJSON{ Name: "Duplicate Name", Pass: false, Callback: "counter", Exists: false, - Key: "happy_path", - JSON: `{"name":"happy_path_histo"}`, + Key: "json_happy_path", + JSON: `{"name":"json_happy_path_histo"}`, }) statsCallback, err := New(Config{}) From 4e1936509cf9e320cac77820c2a63dc2a0a80a79 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 6 Oct 2024 08:06:19 -0700 Subject: [PATCH 09/31] fix(kvstore): declare err inline for cleaner code Tweaking inline variable declaration because, unlike Iron Man, we might need some suits to keep things tidy. --- pkg/callbacks/kvstore/kvstore.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/callbacks/kvstore/kvstore.go b/pkg/callbacks/kvstore/kvstore.go index 844d6499..cc7f802b 100644 --- a/pkg/callbacks/kvstore/kvstore.go +++ b/pkg/callbacks/kvstore/kvstore.go @@ -96,7 +96,7 @@ func (k *KVStore) Get(b []byte) ([]byte, error) { rsp.Data = data } - m, err = pb.Marshal(rsp) + m, err := pb.Marshal(rsp) if err != nil { return nil, fmt.Errorf("unable to marshal kvstore:get response") } @@ -181,7 +181,7 @@ func (k *KVStore) Set(b []byte) ([]byte, error) { } } - m, err = pb.Marshal(rsp) + m, err := pb.Marshal(rsp) if err != nil { return nil, fmt.Errorf("unable to marshal kvstore:set response") } @@ -265,7 +265,7 @@ func (k *KVStore) Delete(b []byte) ([]byte, error) { } } - m, err = pb.Marshal(rsp) + m, err := pb.Marshal(rsp) if err != nil { return nil, fmt.Errorf("unable to marshal kvstore:delete response") } From cc839c5de55482fded6e705d005d97a4b6e25242 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 6 Oct 2024 08:11:49 -0700 Subject: [PATCH 10/31] fix(makefile): switch to docker compose v2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Decided to join the sequel bandwagon by upgrading our makefile from `docker-compose` to `docker compose`. Much like how Terminator 2 improved upon its predecessor, this should streamline our test setups with more consistent results — hopefully without any Schwarzenegger mishaps. --- Makefile | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index d13dfdf9..b77c9905 100644 --- a/Makefile +++ b/Makefile @@ -17,57 +17,57 @@ tests-nobuild: tests-base tests-redis tests-cassandra tests-mysql tests-postgres tests-base: @echo "Launching Tests in Docker Compose" - docker-compose -f dev-compose.yml up -d consul consulator - docker-compose -f dev-compose.yml up --exit-code-from tests-base --build tests-base - docker-compose -f dev-compose.yml down + docker compose -f dev-compose.yml up -d consul consulator + docker compose -f dev-compose.yml up --exit-code-from tests-base --build tests-base + docker compose -f dev-compose.yml down tests-boltdb: @echo "Launching Tests in Docker Compose" - docker-compose -f dev-compose.yml up --exit-code-from tests-boltdb tests-boltdb - docker-compose -f dev-compose.yml down + docker compose -f dev-compose.yml up --exit-code-from tests-boltdb tests-boltdb + docker compose -f dev-compose.yml down tests-inmemory: @echo "Launching Tests in Docker Compose" - docker-compose -f dev-compose.yml up --exit-code-from tests-inmemory tests-inmemory - docker-compose -f dev-compose.yml down + docker compose -f dev-compose.yml up --exit-code-from tests-inmemory tests-inmemory + docker compose -f dev-compose.yml down tests-redis: @echo "Launching Tests in Docker Compose" - docker-compose -f dev-compose.yml up --exit-code-from tests-redis tests-redis - docker-compose -f dev-compose.yml down + docker compose -f dev-compose.yml up --exit-code-from tests-redis tests-redis + docker compose -f dev-compose.yml down tests-cassandra: @echo "Launching Tests in Docker Compose" - docker-compose -f dev-compose.yml up -d cassandra-primary cassandra - docker-compose -f dev-compose.yml up --exit-code-from tests-cassandra tests-cassandra - docker-compose -f dev-compose.yml down + docker compose -f dev-compose.yml up -d cassandra-primary cassandra + docker compose -f dev-compose.yml up --exit-code-from tests-cassandra tests-cassandra + docker compose -f dev-compose.yml down tests-mysql: @echo "Launching Tests in Docker Compose" - docker-compose -f dev-compose.yml up -d mysql - docker-compose -f dev-compose.yml up --exit-code-from tests-mysql tests-mysql - docker-compose -f dev-compose.yml down + docker compose -f dev-compose.yml up -d mysql + docker compose -f dev-compose.yml up --exit-code-from tests-mysql tests-mysql + docker compose -f dev-compose.yml down tests-postgres: @echo "Launching Tests in Docker Compose" - docker-compose -f dev-compose.yml up -d postgres - docker-compose -f dev-compose.yml up --exit-code-from tests-postgres tests-postgres - docker-compose -f dev-compose.yml down + docker compose -f dev-compose.yml up -d postgres + docker compose -f dev-compose.yml up --exit-code-from tests-postgres tests-postgres + docker compose -f dev-compose.yml down benchmarks: @echo "Launching Tests in Docker Compose" - docker-compose -f dev-compose.yml up -d cassandra-primary cassandra mysql + docker compose -f dev-compose.yml up -d cassandra-primary cassandra mysql sleep 120 - docker-compose -f dev-compose.yml up --build benchmarks + docker compose -f dev-compose.yml up --build benchmarks clean: @echo "Cleaning up build junk" - -docker-compose -f dev-compose.yml down + -docker compose -f dev-compose.yml down tarmac: @echo "Starting Application" - docker-compose -f dev-compose.yml up --build tarmac + docker compose -f dev-compose.yml up --build tarmac tarmac-performance: build @echo "Starting Application" - docker-compose -f dev-compose.yml up -d tarmac-performance + docker compose -f dev-compose.yml up -d tarmac-performance From 6f59e44eb95e9da86edc9fc7e17fd7743e4149a4 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 6 Oct 2024 08:17:26 -0700 Subject: [PATCH 11/31] fix(tests): tidy up kvstore tests for binary data Tidying up because even test data deserves to look its best. --- pkg/callbacks/kvstore/kvstore_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/callbacks/kvstore/kvstore_test.go b/pkg/callbacks/kvstore/kvstore_test.go index 3241a9ee..362ddc08 100644 --- a/pkg/callbacks/kvstore/kvstore_test.go +++ b/pkg/callbacks/kvstore/kvstore_test.go @@ -30,7 +30,7 @@ func TestKVStore(t *testing.T) { "Float Value": {0x40, 0x49, 0x0f, 0xdb}, "Boolean Value": {0x01}, "JSON Object": []byte(`{"name":"Test","msg":"Hi!"}`), - "Binary Data": []byte{0x00, 0x01, 0x02, 0x03, 0x04}, + "Binary Data": {0x00, 0x01, 0x02, 0x03, 0x04}, "Special Characters in String": []byte("!@#$%^&*()_+"), } From 126c46e9e1dde10f7aae1405fac978c628784a21 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 6 Oct 2024 08:55:39 -0700 Subject: [PATCH 12/31] feat(kvstore): enhance KVStoreKeys with Proto option - Introduces `KVStoreKeys` with marshaling for proto. - Adds missing `--rm` to Docker operations to clean up afterward, because who wants leftover containers? - Includes Makefile tweaks for a tidier build process. --- pkg/callbacks/kvstore/kvstore_test.go | 8 +- proto/kvstore.pb.go | 115 +++++++++-- proto/kvstore_vtproto.pb.go | 277 ++++++++++++++++++++++++++ testdata/function/Makefile | 2 +- testdata/kv/Makefile | 2 +- testdata/logger/Makefile | 2 +- testdata/sql/Makefile | 2 +- 7 files changed, 383 insertions(+), 25 deletions(-) diff --git a/pkg/callbacks/kvstore/kvstore_test.go b/pkg/callbacks/kvstore/kvstore_test.go index 362ddc08..dff6db07 100644 --- a/pkg/callbacks/kvstore/kvstore_test.go +++ b/pkg/callbacks/kvstore/kvstore_test.go @@ -315,7 +315,13 @@ func TestKVStore(t *testing.T) { t.Fatalf("Failed to create KVStore instance: %v", err) } - rsp, err := k.Keys([]byte{}) + req := &proto.KVStoreKeys{ReturnProto: true} + b, err := pb.Marshal(req) + if err != nil { + t.Fatalf("Failed to marshal request: %v", err) + } + + rsp, err := k.Keys(b) if (err != nil) != c.err { t.Fatalf("Unexpected error state: %v", err) } diff --git a/proto/kvstore.pb.go b/proto/kvstore.pb.go index 82e9db7d..7cbde530 100644 --- a/proto/kvstore.pb.go +++ b/proto/kvstore.pb.go @@ -361,6 +361,65 @@ func (x *KVStoreDeleteResponse) GetStatus() *Status { return nil } +// KVStoreKeys is a structure used to create a Keys callback request to the +// Tarmac KVStore interface. +// +// This structure is a general request type used for all KVStore types provided +// by Tarmac. +type KVStoreKeys struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // ReturnProto is a boolean value that determines if the response should be + // returned as a JSON string or as a KVStoreKeysResponse message. + // + // This must be set to true to return a KVStoreKeysResponse message. + ReturnProto bool `protobuf:"varint,1,opt,name=return_proto,json=returnProto,proto3" json:"return_proto,omitempty"` +} + +func (x *KVStoreKeys) Reset() { + *x = KVStoreKeys{} + if protoimpl.UnsafeEnabled { + mi := &file_kvstore_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *KVStoreKeys) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KVStoreKeys) ProtoMessage() {} + +func (x *KVStoreKeys) ProtoReflect() protoreflect.Message { + mi := &file_kvstore_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use KVStoreKeys.ProtoReflect.Descriptor instead. +func (*KVStoreKeys) Descriptor() ([]byte, []int) { + return file_kvstore_proto_rawDescGZIP(), []int{6} +} + +func (x *KVStoreKeys) GetReturnProto() bool { + if x != nil { + return x.ReturnProto + } + return false +} + +// KVStoreKeysResponse is a structure supplied as a response message to the +// KVStore Keys callback function. +// // This response is a general response type used for all KVStore types provided // by Tarmac. type KVStoreKeysResponse struct { @@ -378,7 +437,7 @@ type KVStoreKeysResponse struct { func (x *KVStoreKeysResponse) Reset() { *x = KVStoreKeysResponse{} if protoimpl.UnsafeEnabled { - mi := &file_kvstore_proto_msgTypes[6] + mi := &file_kvstore_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -391,7 +450,7 @@ func (x *KVStoreKeysResponse) String() string { func (*KVStoreKeysResponse) ProtoMessage() {} func (x *KVStoreKeysResponse) ProtoReflect() protoreflect.Message { - mi := &file_kvstore_proto_msgTypes[6] + mi := &file_kvstore_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -404,7 +463,7 @@ func (x *KVStoreKeysResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use KVStoreKeysResponse.ProtoReflect.Descriptor instead. func (*KVStoreKeysResponse) Descriptor() ([]byte, []int) { - return file_kvstore_proto_rawDescGZIP(), []int{6} + return file_kvstore_proto_rawDescGZIP(), []int{7} } func (x *KVStoreKeysResponse) GetStatus() *Status { @@ -447,15 +506,18 @@ var file_kvstore_proto_rawDesc = []byte{ 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x51, 0x0a, 0x13, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, - 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, - 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2d, 0x70, 0x72, - 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x30, 0x0a, 0x0b, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, + 0x4b, 0x65, 0x79, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x5f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x72, 0x65, 0x74, 0x75, + 0x72, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x51, 0x0a, 0x13, 0x4b, 0x56, 0x53, 0x74, 0x6f, + 0x72, 0x65, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, + 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, + 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2d, + 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -470,7 +532,7 @@ func file_kvstore_proto_rawDescGZIP() []byte { return file_kvstore_proto_rawDescData } -var file_kvstore_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_kvstore_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_kvstore_proto_goTypes = []any{ (*KVStoreGet)(nil), // 0: tarmac.kvstore.KVStoreGet (*KVStoreGetResponse)(nil), // 1: tarmac.kvstore.KVStoreGetResponse @@ -478,14 +540,15 @@ var file_kvstore_proto_goTypes = []any{ (*KVStoreSetResponse)(nil), // 3: tarmac.kvstore.KVStoreSetResponse (*KVStoreDelete)(nil), // 4: tarmac.kvstore.KVStoreDelete (*KVStoreDeleteResponse)(nil), // 5: tarmac.kvstore.KVStoreDeleteResponse - (*KVStoreKeysResponse)(nil), // 6: tarmac.kvstore.KVStoreKeysResponse - (*Status)(nil), // 7: tarmac.Status + (*KVStoreKeys)(nil), // 6: tarmac.kvstore.KVStoreKeys + (*KVStoreKeysResponse)(nil), // 7: tarmac.kvstore.KVStoreKeysResponse + (*Status)(nil), // 8: tarmac.Status } var file_kvstore_proto_depIdxs = []int32{ - 7, // 0: tarmac.kvstore.KVStoreGetResponse.status:type_name -> tarmac.Status - 7, // 1: tarmac.kvstore.KVStoreSetResponse.status:type_name -> tarmac.Status - 7, // 2: tarmac.kvstore.KVStoreDeleteResponse.status:type_name -> tarmac.Status - 7, // 3: tarmac.kvstore.KVStoreKeysResponse.status:type_name -> tarmac.Status + 8, // 0: tarmac.kvstore.KVStoreGetResponse.status:type_name -> tarmac.Status + 8, // 1: tarmac.kvstore.KVStoreSetResponse.status:type_name -> tarmac.Status + 8, // 2: tarmac.kvstore.KVStoreDeleteResponse.status:type_name -> tarmac.Status + 8, // 3: tarmac.kvstore.KVStoreKeysResponse.status:type_name -> tarmac.Status 4, // [4:4] is the sub-list for method output_type 4, // [4:4] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name @@ -573,6 +636,18 @@ func file_kvstore_proto_init() { } } file_kvstore_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*KVStoreKeys); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kvstore_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*KVStoreKeysResponse); i { case 0: return &v.state @@ -591,7 +666,7 @@ func file_kvstore_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_kvstore_proto_rawDesc, NumEnums: 0, - NumMessages: 7, + NumMessages: 8, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/kvstore_vtproto.pb.go b/proto/kvstore_vtproto.pb.go index 7cfb1c67..4fb63b3e 100644 --- a/proto/kvstore_vtproto.pb.go +++ b/proto/kvstore_vtproto.pb.go @@ -132,6 +132,23 @@ func (m *KVStoreDeleteResponse) CloneMessageVT() proto.Message { return m.CloneVT() } +func (m *KVStoreKeys) CloneVT() *KVStoreKeys { + if m == nil { + return (*KVStoreKeys)(nil) + } + r := new(KVStoreKeys) + r.ReturnProto = m.ReturnProto + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *KVStoreKeys) CloneMessageVT() proto.Message { + return m.CloneVT() +} + func (m *KVStoreKeysResponse) CloneVT() *KVStoreKeysResponse { if m == nil { return (*KVStoreKeysResponse)(nil) @@ -274,6 +291,25 @@ func (this *KVStoreDeleteResponse) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } +func (this *KVStoreKeys) EqualVT(that *KVStoreKeys) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.ReturnProto != that.ReturnProto { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *KVStoreKeys) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*KVStoreKeys) + if !ok { + return false + } + return this.EqualVT(that) +} func (this *KVStoreKeysResponse) EqualVT(that *KVStoreKeysResponse) bool { if this == that { return true @@ -565,6 +601,49 @@ func (m *KVStoreDeleteResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *KVStoreKeys) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreKeys) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *KVStoreKeys) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.ReturnProto { + i-- + if m.ReturnProto { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *KVStoreKeysResponse) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil @@ -880,6 +959,49 @@ func (m *KVStoreDeleteResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *KVStoreKeys) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KVStoreKeys) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *KVStoreKeys) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.ReturnProto { + i-- + if m.ReturnProto { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *KVStoreKeysResponse) MarshalVTStrict() (dAtA []byte, err error) { if m == nil { return nil, nil @@ -1024,6 +1146,19 @@ func (m *KVStoreDeleteResponse) SizeVT() (n int) { return n } +func (m *KVStoreKeys) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ReturnProto { + n += 2 + } + n += len(m.unknownFields) + return n +} + func (m *KVStoreKeysResponse) SizeVT() (n int) { if m == nil { return 0 @@ -1622,6 +1757,77 @@ func (m *KVStoreDeleteResponse) UnmarshalVT(dAtA []byte) error { } return nil } +func (m *KVStoreKeys) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreKeys: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreKeys: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReturnProto", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ReturnProto = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *KVStoreKeysResponse) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2325,6 +2531,77 @@ func (m *KVStoreDeleteResponse) UnmarshalVTUnsafe(dAtA []byte) error { } return nil } +func (m *KVStoreKeys) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KVStoreKeys: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KVStoreKeys: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReturnProto", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ReturnProto = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *KVStoreKeysResponse) UnmarshalVTUnsafe(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/testdata/function/Makefile b/testdata/function/Makefile index 23defda8..5137f2ae 100644 --- a/testdata/function/Makefile +++ b/testdata/function/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up diff --git a/testdata/kv/Makefile b/testdata/kv/Makefile index 23defda8..5137f2ae 100644 --- a/testdata/kv/Makefile +++ b/testdata/kv/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up diff --git a/testdata/logger/Makefile b/testdata/logger/Makefile index 23defda8..5137f2ae 100644 --- a/testdata/logger/Makefile +++ b/testdata/logger/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up diff --git a/testdata/sql/Makefile b/testdata/sql/Makefile index 23defda8..5137f2ae 100644 --- a/testdata/sql/Makefile +++ b/testdata/sql/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up From d27ba948c17dad060dc142f394063ed637a92381 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 6 Oct 2024 09:17:13 -0700 Subject: [PATCH 13/31] fix(kvstore): handle empty input in keys function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified the conditional check to accurately handle empty inputs. Because, sometimes, zero really does mean everything – especially to a bug. --- pkg/callbacks/kvstore/kvstore.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/callbacks/kvstore/kvstore.go b/pkg/callbacks/kvstore/kvstore.go index cc7f802b..6c0562aa 100644 --- a/pkg/callbacks/kvstore/kvstore.go +++ b/pkg/callbacks/kvstore/kvstore.go @@ -315,7 +315,7 @@ func (k *KVStore) deleteJSON(b []byte) ([]byte, error) { } func (k *KVStore) Keys(b []byte) ([]byte, error) { - if len(b) > 0 { + if len(b) == 0 { return k.keysJSON(b) } From 2fb9febed82722c1efc8d590f4b1c9412e90fcfb Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 6 Oct 2024 15:53:07 -0700 Subject: [PATCH 14/31] chore: moving protobuf to package --- go.mod | 7 +- go.sum | 6 +- pkg/callbacks/httpclient/httpclient.go | 6 +- pkg/callbacks/httpclient/httpclient_test.go | 3 +- pkg/callbacks/kvstore/kvstore.go | 11 +- pkg/callbacks/kvstore/kvstore_test.go | 2 +- pkg/callbacks/metrics/metrics.go | 2 +- pkg/callbacks/metrics/metrics_test.go | 2 +- pkg/callbacks/sql/sql.go | 7 +- pkg/callbacks/sql/sql_test.go | 2 +- proto/http.pb.go | 311 --- proto/http_vtproto.pb.go | 1680 ------------ proto/kvstore.pb.go | 681 ----- proto/kvstore_vtproto.pb.go | 2727 ------------------- proto/metrics.pb.go | 300 -- proto/metrics_vtproto.pb.go | 1055 ------- proto/sql.pb.go | 400 --- proto/sql_vtproto.pb.go | 1551 ----------- proto/tarmac.pb.go | 163 -- proto/tarmac_vtproto.pb.go | 377 --- 20 files changed, 28 insertions(+), 9265 deletions(-) delete mode 100644 proto/http.pb.go delete mode 100644 proto/http_vtproto.pb.go delete mode 100644 proto/kvstore.pb.go delete mode 100644 proto/kvstore_vtproto.pb.go delete mode 100644 proto/metrics.pb.go delete mode 100644 proto/metrics_vtproto.pb.go delete mode 100644 proto/sql.pb.go delete mode 100644 proto/sql_vtproto.pb.go delete mode 100644 proto/tarmac.pb.go delete mode 100644 proto/tarmac_vtproto.pb.go diff --git a/go.mod b/go.mod index 5c4e617b..1d963fb7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/tarmac-project/tarmac -go 1.22.3 +go 1.22.6 require ( github.com/go-sql-driver/mysql v1.7.1 @@ -8,7 +8,6 @@ require ( github.com/lib/pq v1.10.9 github.com/madflojo/tasks v1.2.0 github.com/madflojo/testcerts v1.2.0 - github.com/planetscale/vtprotobuf v0.6.0 github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 github.com/prometheus/client_golang v1.19.1 github.com/sirupsen/logrus v1.9.3 @@ -19,10 +18,11 @@ require ( github.com/tarmac-project/hord/drivers/hashmap v0.6.0 github.com/tarmac-project/hord/drivers/mock v0.6.0 github.com/tarmac-project/hord/drivers/redis v0.6.0 + github.com/tarmac-project/protobuf-go v0.0.0-20241006222441-51664fb11f56 github.com/tarmac-project/wapc-toolkit/callbacks v0.2.0 github.com/tarmac-project/wapc-toolkit/engine v0.2.0 github.com/wapc/wapc-go v0.7.0 - google.golang.org/protobuf v1.33.0 + google.golang.org/protobuf v1.34.2 ) require ( @@ -77,6 +77,7 @@ require ( github.com/nats-io/nuid v1.0.1 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/planetscale/vtprotobuf v0.6.0 // indirect github.com/prometheus/client_model v0.5.0 // indirect github.com/prometheus/common v0.48.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect diff --git a/go.sum b/go.sum index a40d275a..48e72aee 100644 --- a/go.sum +++ b/go.sum @@ -341,6 +341,8 @@ github.com/tarmac-project/hord/drivers/mock v0.6.0 h1:8XWfpW9I16TN1ycSRf/JU+0Oq+ github.com/tarmac-project/hord/drivers/mock v0.6.0/go.mod h1:B3kPMdUK3M2OoSPktP9Dm+JrllW2DMDeHeUGa41CNzc= github.com/tarmac-project/hord/drivers/redis v0.6.0 h1:jqRydEdOGQxo2GUspOmNk77ebuQkfgYsCMMZ1aRM0io= github.com/tarmac-project/hord/drivers/redis v0.6.0/go.mod h1:dZyQBCqPLmYsXd2kbW1H4pqCWgjFZXTN4xZm36+qF6M= +github.com/tarmac-project/protobuf-go v0.0.0-20241006222441-51664fb11f56 h1:lWWclbcicMaIUdlwIUSaVnAOmhwqpjVDAgUGmK5Dxb8= +github.com/tarmac-project/protobuf-go v0.0.0-20241006222441-51664fb11f56/go.mod h1:TtJAJlZ8d1xmkN32J8HHtvWOBPZMxEOg//yJeBXfbmw= github.com/tarmac-project/wapc-toolkit/callbacks v0.2.0 h1:gsUrXz8EtRf2CpacwaguBHWttQn9k35hhzm9NkoaJIc= github.com/tarmac-project/wapc-toolkit/callbacks v0.2.0/go.mod h1:FvKVFIKPU/r1qTWzMXhM0dv1z6bz5Tv7efLaT+P92Es= github.com/tarmac-project/wapc-toolkit/engine v0.2.0 h1:Lc0goE9E1LyFvNxbzq70ePrk5XdPJU7Zu33vRKwR6sQ= @@ -524,8 +526,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/pkg/callbacks/httpclient/httpclient.go b/pkg/callbacks/httpclient/httpclient.go index e304e695..9de27a6e 100644 --- a/pkg/callbacks/httpclient/httpclient.go +++ b/pkg/callbacks/httpclient/httpclient.go @@ -28,7 +28,9 @@ import ( "github.com/pquerna/ffjson/ffjson" "github.com/tarmac-project/tarmac" - "github.com/tarmac-project/tarmac/proto" + + "github.com/tarmac-project/protobuf-go/sdk" + proto "github.com/tarmac-project/protobuf-go/sdk/http" pb "google.golang.org/protobuf/proto" ) @@ -62,7 +64,7 @@ func (hc *HTTPClient) Call(b []byte) ([]byte, error) { // Create HTTPClientResponse r := &proto.HTTPClientResponse{} - r.Status = &proto.Status{Code: 200, Status: "OK"} + r.Status = &sdk.Status{Code: 200, Status: "OK"} // Create HTTP Client var request *http.Request diff --git a/pkg/callbacks/httpclient/httpclient_test.go b/pkg/callbacks/httpclient/httpclient_test.go index ed14c8ac..8586fdd8 100644 --- a/pkg/callbacks/httpclient/httpclient_test.go +++ b/pkg/callbacks/httpclient/httpclient_test.go @@ -11,7 +11,8 @@ import ( "github.com/pquerna/ffjson/ffjson" "github.com/tarmac-project/tarmac" - "github.com/tarmac-project/tarmac/proto" + + proto "github.com/tarmac-project/protobuf-go/sdk/http" pb "google.golang.org/protobuf/proto" ) diff --git a/pkg/callbacks/kvstore/kvstore.go b/pkg/callbacks/kvstore/kvstore.go index 6c0562aa..49c285a5 100644 --- a/pkg/callbacks/kvstore/kvstore.go +++ b/pkg/callbacks/kvstore/kvstore.go @@ -27,7 +27,8 @@ import ( "github.com/tarmac-project/hord" "github.com/tarmac-project/tarmac" - "github.com/tarmac-project/tarmac/proto" + "github.com/tarmac-project/protobuf-go/sdk" + proto "github.com/tarmac-project/protobuf-go/sdk/kvstore" pb "google.golang.org/protobuf/proto" ) @@ -75,7 +76,7 @@ func (k *KVStore) Get(b []byte) ([]byte, error) { } rsp := &proto.KVStoreGetResponse{ - Status: &proto.Status{ + Status: &sdk.Status{ Code: 200, Status: "OK", }, @@ -157,7 +158,7 @@ func (k *KVStore) Set(b []byte) ([]byte, error) { } rsp := &proto.KVStoreSetResponse{ - Status: &proto.Status{ + Status: &sdk.Status{ Code: 200, Status: "OK", }, @@ -246,7 +247,7 @@ func (k *KVStore) Delete(b []byte) ([]byte, error) { } rsp := &proto.KVStoreDeleteResponse{ - Status: &proto.Status{ + Status: &sdk.Status{ Code: 200, Status: "OK", }, @@ -320,7 +321,7 @@ func (k *KVStore) Keys(b []byte) ([]byte, error) { } rsp := &proto.KVStoreKeysResponse{ - Status: &proto.Status{ + Status: &sdk.Status{ Code: 200, Status: "OK", }, diff --git a/pkg/callbacks/kvstore/kvstore_test.go b/pkg/callbacks/kvstore/kvstore_test.go index dff6db07..fab3aae2 100644 --- a/pkg/callbacks/kvstore/kvstore_test.go +++ b/pkg/callbacks/kvstore/kvstore_test.go @@ -9,7 +9,7 @@ import ( "github.com/tarmac-project/hord/drivers/mock" "github.com/tarmac-project/tarmac" - "github.com/tarmac-project/tarmac/proto" + proto "github.com/tarmac-project/protobuf-go/sdk/kvstore" pb "google.golang.org/protobuf/proto" ) diff --git a/pkg/callbacks/metrics/metrics.go b/pkg/callbacks/metrics/metrics.go index c21901d5..f927f5e4 100644 --- a/pkg/callbacks/metrics/metrics.go +++ b/pkg/callbacks/metrics/metrics.go @@ -27,7 +27,7 @@ import ( "github.com/prometheus/client_golang/prometheus/promauto" "github.com/tarmac-project/tarmac" - "github.com/tarmac-project/tarmac/proto" + proto "github.com/tarmac-project/protobuf-go/sdk/metrics" pb "google.golang.org/protobuf/proto" ) diff --git a/pkg/callbacks/metrics/metrics_test.go b/pkg/callbacks/metrics/metrics_test.go index c99b925c..467e00e7 100644 --- a/pkg/callbacks/metrics/metrics_test.go +++ b/pkg/callbacks/metrics/metrics_test.go @@ -3,7 +3,7 @@ package metrics import ( "testing" - "github.com/tarmac-project/tarmac/proto" + proto "github.com/tarmac-project/protobuf-go/sdk/metrics" pb "google.golang.org/protobuf/proto" ) diff --git a/pkg/callbacks/sql/sql.go b/pkg/callbacks/sql/sql.go index c50e9e14..1a1b939a 100644 --- a/pkg/callbacks/sql/sql.go +++ b/pkg/callbacks/sql/sql.go @@ -25,7 +25,8 @@ import ( "github.com/pquerna/ffjson/ffjson" "github.com/tarmac-project/tarmac" - "github.com/tarmac-project/tarmac/proto" + "github.com/tarmac-project/protobuf-go/sdk" + proto "github.com/tarmac-project/protobuf-go/sdk/sql" pb "google.golang.org/protobuf/proto" ) @@ -67,7 +68,7 @@ func (db *Database) Exec(b []byte) ([]byte, error) { } r := &proto.SQLExecResponse{} - r.Status = &proto.Status{Code: 200, Status: "OK"} + r.Status = &sdk.Status{Code: 200, Status: "OK"} if len(msg.Query) < 1 { r.Status.Code = 400 @@ -128,7 +129,7 @@ func (db *Database) Query(b []byte) ([]byte, error) { // Create a new SQLQueryResponse r := &proto.SQLQueryResponse{} - r.Status = &proto.Status{Code: 200, Status: "OK"} + r.Status = &sdk.Status{Code: 200, Status: "OK"} if len(msg.Query) < 1 { r.Status.Code = 400 diff --git a/pkg/callbacks/sql/sql_test.go b/pkg/callbacks/sql/sql_test.go index 63ba57a3..6e71aa69 100644 --- a/pkg/callbacks/sql/sql_test.go +++ b/pkg/callbacks/sql/sql_test.go @@ -12,7 +12,7 @@ import ( "github.com/pquerna/ffjson/ffjson" "github.com/tarmac-project/tarmac" - "github.com/tarmac-project/tarmac/proto" + proto "github.com/tarmac-project/protobuf-go/sdk/sql" pb "google.golang.org/protobuf/proto" ) diff --git a/proto/http.pb.go b/proto/http.pb.go deleted file mode 100644 index d1224a31..00000000 --- a/proto/http.pb.go +++ /dev/null @@ -1,311 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.3 -// source: http.proto - -package proto - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// HTTPClient is a structure used to create HTTP calls to remote systems. -type HTTPClient struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Method is the HTTP method type for the HTTP request; valid options are - // GET, POST, PUT, PATCH, HEAD, & DELETE. - Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` - // Headers are the HTTP headers to include in the HTTP request. - Headers map[string]string `protobuf:"bytes,2,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // URL is the HTTP URL to call. - Url string `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"` - // Body is the user-supplied HTTP body data. This field should contain the - // request payload data. - Body []byte `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"` - // Insecure will disable TLS host verification; this is common with - // self-signed certificates; however, use caution. - Insecure bool `protobuf:"varint,5,opt,name=insecure,proto3" json:"insecure,omitempty"` -} - -func (x *HTTPClient) Reset() { - *x = HTTPClient{} - if protoimpl.UnsafeEnabled { - mi := &file_http_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HTTPClient) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HTTPClient) ProtoMessage() {} - -func (x *HTTPClient) ProtoReflect() protoreflect.Message { - mi := &file_http_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HTTPClient.ProtoReflect.Descriptor instead. -func (*HTTPClient) Descriptor() ([]byte, []int) { - return file_http_proto_rawDescGZIP(), []int{0} -} - -func (x *HTTPClient) GetMethod() string { - if x != nil { - return x.Method - } - return "" -} - -func (x *HTTPClient) GetHeaders() map[string]string { - if x != nil { - return x.Headers - } - return nil -} - -func (x *HTTPClient) GetUrl() string { - if x != nil { - return x.Url - } - return "" -} - -func (x *HTTPClient) GetBody() []byte { - if x != nil { - return x.Body - } - return nil -} - -func (x *HTTPClient) GetInsecure() bool { - if x != nil { - return x.Insecure - } - return false -} - -// HTTPClientResponse is a structure supplied as a response message to a remote -// HTTP call callback function. -type HTTPClientResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Status is the human readable error message or success message for function - // execution. - Status *Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` - // Code is the HTTP Status Code returned from the target server. - Code int32 `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"` - // Headers are the HTTP headers returned from the HTTP request. - Headers map[string]string `protobuf:"bytes,3,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // Body is the server-supplied HTTP payload data. The server-supplied payload - // will be a byte slice. - Body []byte `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"` -} - -func (x *HTTPClientResponse) Reset() { - *x = HTTPClientResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_http_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HTTPClientResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HTTPClientResponse) ProtoMessage() {} - -func (x *HTTPClientResponse) ProtoReflect() protoreflect.Message { - mi := &file_http_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HTTPClientResponse.ProtoReflect.Descriptor instead. -func (*HTTPClientResponse) Descriptor() ([]byte, []int) { - return file_http_proto_rawDescGZIP(), []int{1} -} - -func (x *HTTPClientResponse) GetStatus() *Status { - if x != nil { - return x.Status - } - return nil -} - -func (x *HTTPClientResponse) GetCode() int32 { - if x != nil { - return x.Code - } - return 0 -} - -func (x *HTTPClientResponse) GetHeaders() map[string]string { - if x != nil { - return x.Headers - } - return nil -} - -func (x *HTTPClientResponse) GetBody() []byte { - if x != nil { - return x.Body - } - return nil -} - -var File_http_proto protoreflect.FileDescriptor - -var file_http_proto_rawDesc = []byte{ - 0x0a, 0x0a, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x74, 0x61, - 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x1a, 0x0c, 0x74, 0x61, 0x72, 0x6d, 0x61, - 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe2, 0x01, 0x0a, 0x0a, 0x48, 0x54, 0x54, 0x50, - 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x3e, - 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x24, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x48, 0x54, - 0x54, 0x50, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x10, - 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, - 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, - 0x62, 0x6f, 0x64, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, - 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xe8, 0x01, 0x0a, - 0x12, 0x48, 0x54, 0x54, 0x50, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x63, - 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, - 0x46, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x2c, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x48, - 0x54, 0x54, 0x50, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, - 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2d, 0x70, 0x72, 0x6f, - 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_http_proto_rawDescOnce sync.Once - file_http_proto_rawDescData = file_http_proto_rawDesc -) - -func file_http_proto_rawDescGZIP() []byte { - file_http_proto_rawDescOnce.Do(func() { - file_http_proto_rawDescData = protoimpl.X.CompressGZIP(file_http_proto_rawDescData) - }) - return file_http_proto_rawDescData -} - -var file_http_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_http_proto_goTypes = []any{ - (*HTTPClient)(nil), // 0: tarmac.http.HTTPClient - (*HTTPClientResponse)(nil), // 1: tarmac.http.HTTPClientResponse - nil, // 2: tarmac.http.HTTPClient.HeadersEntry - nil, // 3: tarmac.http.HTTPClientResponse.HeadersEntry - (*Status)(nil), // 4: tarmac.Status -} -var file_http_proto_depIdxs = []int32{ - 2, // 0: tarmac.http.HTTPClient.headers:type_name -> tarmac.http.HTTPClient.HeadersEntry - 4, // 1: tarmac.http.HTTPClientResponse.status:type_name -> tarmac.Status - 3, // 2: tarmac.http.HTTPClientResponse.headers:type_name -> tarmac.http.HTTPClientResponse.HeadersEntry - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name -} - -func init() { file_http_proto_init() } -func file_http_proto_init() { - if File_http_proto != nil { - return - } - file_tarmac_proto_init() - if !protoimpl.UnsafeEnabled { - file_http_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*HTTPClient); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_http_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*HTTPClientResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_http_proto_rawDesc, - NumEnums: 0, - NumMessages: 4, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_http_proto_goTypes, - DependencyIndexes: file_http_proto_depIdxs, - MessageInfos: file_http_proto_msgTypes, - }.Build() - File_http_proto = out.File - file_http_proto_rawDesc = nil - file_http_proto_goTypes = nil - file_http_proto_depIdxs = nil -} diff --git a/proto/http_vtproto.pb.go b/proto/http_vtproto.pb.go deleted file mode 100644 index ab3a2edb..00000000 --- a/proto/http_vtproto.pb.go +++ /dev/null @@ -1,1680 +0,0 @@ -// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. -// protoc-gen-go-vtproto version: v0.6.0 -// source: http.proto - -package proto - -import ( - fmt "fmt" - protohelpers "github.com/planetscale/vtprotobuf/protohelpers" - proto "google.golang.org/protobuf/proto" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -func (m *HTTPClient) CloneVT() *HTTPClient { - if m == nil { - return (*HTTPClient)(nil) - } - r := new(HTTPClient) - r.Method = m.Method - r.Url = m.Url - r.Insecure = m.Insecure - if rhs := m.Headers; rhs != nil { - tmpContainer := make(map[string]string, len(rhs)) - for k, v := range rhs { - tmpContainer[k] = v - } - r.Headers = tmpContainer - } - if rhs := m.Body; rhs != nil { - tmpBytes := make([]byte, len(rhs)) - copy(tmpBytes, rhs) - r.Body = tmpBytes - } - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *HTTPClient) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (m *HTTPClientResponse) CloneVT() *HTTPClientResponse { - if m == nil { - return (*HTTPClientResponse)(nil) - } - r := new(HTTPClientResponse) - r.Status = m.Status.CloneVT() - r.Code = m.Code - if rhs := m.Headers; rhs != nil { - tmpContainer := make(map[string]string, len(rhs)) - for k, v := range rhs { - tmpContainer[k] = v - } - r.Headers = tmpContainer - } - if rhs := m.Body; rhs != nil { - tmpBytes := make([]byte, len(rhs)) - copy(tmpBytes, rhs) - r.Body = tmpBytes - } - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *HTTPClientResponse) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (this *HTTPClient) EqualVT(that *HTTPClient) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if this.Method != that.Method { - return false - } - if len(this.Headers) != len(that.Headers) { - return false - } - for i, vx := range this.Headers { - vy, ok := that.Headers[i] - if !ok { - return false - } - if vx != vy { - return false - } - } - if this.Url != that.Url { - return false - } - if string(this.Body) != string(that.Body) { - return false - } - if this.Insecure != that.Insecure { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *HTTPClient) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*HTTPClient) - if !ok { - return false - } - return this.EqualVT(that) -} -func (this *HTTPClientResponse) EqualVT(that *HTTPClientResponse) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if !this.Status.EqualVT(that.Status) { - return false - } - if this.Code != that.Code { - return false - } - if len(this.Headers) != len(that.Headers) { - return false - } - for i, vx := range this.Headers { - vy, ok := that.Headers[i] - if !ok { - return false - } - if vx != vy { - return false - } - } - if string(this.Body) != string(that.Body) { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *HTTPClientResponse) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*HTTPClientResponse) - if !ok { - return false - } - return this.EqualVT(that) -} -func (m *HTTPClient) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *HTTPClient) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *HTTPClient) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.Insecure { - i-- - if m.Insecure { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x28 - } - if len(m.Body) > 0 { - i -= len(m.Body) - copy(dAtA[i:], m.Body) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Body))) - i-- - dAtA[i] = 0x22 - } - if len(m.Url) > 0 { - i -= len(m.Url) - copy(dAtA[i:], m.Url) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Url))) - i-- - dAtA[i] = 0x1a - } - if len(m.Headers) > 0 { - for k := range m.Headers { - v := m.Headers[k] - baseI := i - i -= len(v) - copy(dAtA[i:], v) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) - i-- - dAtA[i] = 0x12 - i -= len(k) - copy(dAtA[i:], k) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x12 - } - } - if len(m.Method) > 0 { - i -= len(m.Method) - copy(dAtA[i:], m.Method) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Method))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *HTTPClientResponse) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *HTTPClientResponse) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *HTTPClientResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Body) > 0 { - i -= len(m.Body) - copy(dAtA[i:], m.Body) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Body))) - i-- - dAtA[i] = 0x22 - } - if len(m.Headers) > 0 { - for k := range m.Headers { - v := m.Headers[k] - baseI := i - i -= len(v) - copy(dAtA[i:], v) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) - i-- - dAtA[i] = 0x12 - i -= len(k) - copy(dAtA[i:], k) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x1a - } - } - if m.Code != 0 { - i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Code)) - i-- - dAtA[i] = 0x10 - } - if m.Status != nil { - size, err := m.Status.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *HTTPClient) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *HTTPClient) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *HTTPClient) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.Insecure { - i-- - if m.Insecure { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x28 - } - if len(m.Body) > 0 { - i -= len(m.Body) - copy(dAtA[i:], m.Body) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Body))) - i-- - dAtA[i] = 0x22 - } - if len(m.Url) > 0 { - i -= len(m.Url) - copy(dAtA[i:], m.Url) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Url))) - i-- - dAtA[i] = 0x1a - } - if len(m.Headers) > 0 { - for k := range m.Headers { - v := m.Headers[k] - baseI := i - i -= len(v) - copy(dAtA[i:], v) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) - i-- - dAtA[i] = 0x12 - i -= len(k) - copy(dAtA[i:], k) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x12 - } - } - if len(m.Method) > 0 { - i -= len(m.Method) - copy(dAtA[i:], m.Method) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Method))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *HTTPClientResponse) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *HTTPClientResponse) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *HTTPClientResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Body) > 0 { - i -= len(m.Body) - copy(dAtA[i:], m.Body) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Body))) - i-- - dAtA[i] = 0x22 - } - if len(m.Headers) > 0 { - for k := range m.Headers { - v := m.Headers[k] - baseI := i - i -= len(v) - copy(dAtA[i:], v) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) - i-- - dAtA[i] = 0x12 - i -= len(k) - copy(dAtA[i:], k) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x1a - } - } - if m.Code != 0 { - i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Code)) - i-- - dAtA[i] = 0x10 - } - if m.Status != nil { - size, err := m.Status.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *HTTPClient) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Method) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - if len(m.Headers) > 0 { - for k, v := range m.Headers { - _ = k - _ = v - mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + 1 + len(v) + protohelpers.SizeOfVarint(uint64(len(v))) - n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) - } - } - l = len(m.Url) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - l = len(m.Body) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - if m.Insecure { - n += 2 - } - n += len(m.unknownFields) - return n -} - -func (m *HTTPClientResponse) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Status != nil { - l = m.Status.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - if m.Code != 0 { - n += 1 + protohelpers.SizeOfVarint(uint64(m.Code)) - } - if len(m.Headers) > 0 { - for k, v := range m.Headers { - _ = k - _ = v - mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + 1 + len(v) + protohelpers.SizeOfVarint(uint64(len(v))) - n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) - } - } - l = len(m.Body) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *HTTPClient) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: HTTPClient: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HTTPClient: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Method", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Method = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Headers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Headers == nil { - m.Headers = make(map[string]string) - } - var mapkey string - var mapvalue string - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return protohelpers.ErrInvalidLength - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return protohelpers.ErrInvalidLength - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var stringLenmapvalue uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapvalue |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapvalue := int(stringLenmapvalue) - if intStringLenmapvalue < 0 { - return protohelpers.ErrInvalidLength - } - postStringIndexmapvalue := iNdEx + intStringLenmapvalue - if postStringIndexmapvalue < 0 { - return protohelpers.ErrInvalidLength - } - if postStringIndexmapvalue > l { - return io.ErrUnexpectedEOF - } - mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) - iNdEx = postStringIndexmapvalue - } else { - iNdEx = entryPreIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.Headers[mapkey] = mapvalue - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Url", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Url = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Body = append(m.Body[:0], dAtA[iNdEx:postIndex]...) - if m.Body == nil { - m.Body = []byte{} - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Insecure", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Insecure = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *HTTPClientResponse) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: HTTPClientResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HTTPClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &Status{} - } - if err := m.Status.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) - } - m.Code = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Code |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Headers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Headers == nil { - m.Headers = make(map[string]string) - } - var mapkey string - var mapvalue string - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return protohelpers.ErrInvalidLength - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return protohelpers.ErrInvalidLength - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var stringLenmapvalue uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapvalue |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapvalue := int(stringLenmapvalue) - if intStringLenmapvalue < 0 { - return protohelpers.ErrInvalidLength - } - postStringIndexmapvalue := iNdEx + intStringLenmapvalue - if postStringIndexmapvalue < 0 { - return protohelpers.ErrInvalidLength - } - if postStringIndexmapvalue > l { - return io.ErrUnexpectedEOF - } - mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) - iNdEx = postStringIndexmapvalue - } else { - iNdEx = entryPreIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.Headers[mapkey] = mapvalue - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Body = append(m.Body[:0], dAtA[iNdEx:postIndex]...) - if m.Body == nil { - m.Body = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *HTTPClient) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: HTTPClient: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HTTPClient: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Method", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var stringValue string - if intStringLen > 0 { - stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) - } - m.Method = stringValue - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Headers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Headers == nil { - m.Headers = make(map[string]string) - } - var mapkey string - var mapvalue string - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return protohelpers.ErrInvalidLength - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return protohelpers.ErrInvalidLength - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - if intStringLenmapkey == 0 { - mapkey = "" - } else { - mapkey = unsafe.String(&dAtA[iNdEx], intStringLenmapkey) - } - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var stringLenmapvalue uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapvalue |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapvalue := int(stringLenmapvalue) - if intStringLenmapvalue < 0 { - return protohelpers.ErrInvalidLength - } - postStringIndexmapvalue := iNdEx + intStringLenmapvalue - if postStringIndexmapvalue < 0 { - return protohelpers.ErrInvalidLength - } - if postStringIndexmapvalue > l { - return io.ErrUnexpectedEOF - } - if intStringLenmapvalue == 0 { - mapvalue = "" - } else { - mapvalue = unsafe.String(&dAtA[iNdEx], intStringLenmapvalue) - } - iNdEx = postStringIndexmapvalue - } else { - iNdEx = entryPreIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.Headers[mapkey] = mapvalue - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Url", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var stringValue string - if intStringLen > 0 { - stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) - } - m.Url = stringValue - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Body = dAtA[iNdEx:postIndex] - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Insecure", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Insecure = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *HTTPClientResponse) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: HTTPClientResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HTTPClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &Status{} - } - if err := m.Status.UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) - } - m.Code = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Code |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Headers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Headers == nil { - m.Headers = make(map[string]string) - } - var mapkey string - var mapvalue string - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return protohelpers.ErrInvalidLength - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return protohelpers.ErrInvalidLength - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - if intStringLenmapkey == 0 { - mapkey = "" - } else { - mapkey = unsafe.String(&dAtA[iNdEx], intStringLenmapkey) - } - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var stringLenmapvalue uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapvalue |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapvalue := int(stringLenmapvalue) - if intStringLenmapvalue < 0 { - return protohelpers.ErrInvalidLength - } - postStringIndexmapvalue := iNdEx + intStringLenmapvalue - if postStringIndexmapvalue < 0 { - return protohelpers.ErrInvalidLength - } - if postStringIndexmapvalue > l { - return io.ErrUnexpectedEOF - } - if intStringLenmapvalue == 0 { - mapvalue = "" - } else { - mapvalue = unsafe.String(&dAtA[iNdEx], intStringLenmapvalue) - } - iNdEx = postStringIndexmapvalue - } else { - iNdEx = entryPreIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.Headers[mapkey] = mapvalue - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Body = dAtA[iNdEx:postIndex] - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} diff --git a/proto/kvstore.pb.go b/proto/kvstore.pb.go deleted file mode 100644 index 7cbde530..00000000 --- a/proto/kvstore.pb.go +++ /dev/null @@ -1,681 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.3 -// source: kvstore.proto - -package proto - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// KVStoreGet is a structure used to create Get request callbacks to the Tarmac -// KVStore interface. -// -// This structure is a general request type used for all KVStore types provided -// by Tarmac. -type KVStoreGet struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Key is the index key to use when accessing the key:value store. - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` -} - -func (x *KVStoreGet) Reset() { - *x = KVStoreGet{} - if protoimpl.UnsafeEnabled { - mi := &file_kvstore_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *KVStoreGet) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*KVStoreGet) ProtoMessage() {} - -func (x *KVStoreGet) ProtoReflect() protoreflect.Message { - mi := &file_kvstore_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use KVStoreGet.ProtoReflect.Descriptor instead. -func (*KVStoreGet) Descriptor() ([]byte, []int) { - return file_kvstore_proto_rawDescGZIP(), []int{0} -} - -func (x *KVStoreGet) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -// KVStoreGetResponse is a structure supplied as response messages to KVStore -// Get requests. -// -// This response is a general response type used for all KVStore types provided -// by Tarmac. -type KVStoreGetResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Status is the human readable error message or success message for function - // execution. - Status *Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` - // Data is the response data provided by the key:value store. - // This data is a byte slice to provide a simple field for arbitrary data. - Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` -} - -func (x *KVStoreGetResponse) Reset() { - *x = KVStoreGetResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_kvstore_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *KVStoreGetResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*KVStoreGetResponse) ProtoMessage() {} - -func (x *KVStoreGetResponse) ProtoReflect() protoreflect.Message { - mi := &file_kvstore_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use KVStoreGetResponse.ProtoReflect.Descriptor instead. -func (*KVStoreGetResponse) Descriptor() ([]byte, []int) { - return file_kvstore_proto_rawDescGZIP(), []int{1} -} - -func (x *KVStoreGetResponse) GetStatus() *Status { - if x != nil { - return x.Status - } - return nil -} - -func (x *KVStoreGetResponse) GetData() []byte { - if x != nil { - return x.Data - } - return nil -} - -// KVStoreSet is a structure used to create a Set request callback to the -// Tarmac KVStore interface. -// -// This structure is a general request type used for all KVStore types provided -// by Tarmac. -type KVStoreSet struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Key is the index key used to store the data. - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - // Data is the user-supplied key:value data. - // Tarmac expects this field to be a byte slice. - Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` -} - -func (x *KVStoreSet) Reset() { - *x = KVStoreSet{} - if protoimpl.UnsafeEnabled { - mi := &file_kvstore_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *KVStoreSet) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*KVStoreSet) ProtoMessage() {} - -func (x *KVStoreSet) ProtoReflect() protoreflect.Message { - mi := &file_kvstore_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use KVStoreSet.ProtoReflect.Descriptor instead. -func (*KVStoreSet) Descriptor() ([]byte, []int) { - return file_kvstore_proto_rawDescGZIP(), []int{2} -} - -func (x *KVStoreSet) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -func (x *KVStoreSet) GetData() []byte { - if x != nil { - return x.Data - } - return nil -} - -// KVStoreSetResponse is a structure supplied as a response message to the -// KVStore Set callback function. -// -// This response is a general response type used for all KVStore types provided -// by Tarmac. -type KVStoreSetResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Status is the human readable error message or success message for function - // execution. - Status *Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` -} - -func (x *KVStoreSetResponse) Reset() { - *x = KVStoreSetResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_kvstore_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *KVStoreSetResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*KVStoreSetResponse) ProtoMessage() {} - -func (x *KVStoreSetResponse) ProtoReflect() protoreflect.Message { - mi := &file_kvstore_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use KVStoreSetResponse.ProtoReflect.Descriptor instead. -func (*KVStoreSetResponse) Descriptor() ([]byte, []int) { - return file_kvstore_proto_rawDescGZIP(), []int{3} -} - -func (x *KVStoreSetResponse) GetStatus() *Status { - if x != nil { - return x.Status - } - return nil -} - -// KVStoreDelete is a structure used to create Delete callback requests to the -// Tarmac KVStore interface. -// -// This structure is a general request type used for all KVStore types provided -// by Tarmac. -type KVStoreDelete struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Key is the index key used to store the data. - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` -} - -func (x *KVStoreDelete) Reset() { - *x = KVStoreDelete{} - if protoimpl.UnsafeEnabled { - mi := &file_kvstore_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *KVStoreDelete) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*KVStoreDelete) ProtoMessage() {} - -func (x *KVStoreDelete) ProtoReflect() protoreflect.Message { - mi := &file_kvstore_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use KVStoreDelete.ProtoReflect.Descriptor instead. -func (*KVStoreDelete) Descriptor() ([]byte, []int) { - return file_kvstore_proto_rawDescGZIP(), []int{4} -} - -func (x *KVStoreDelete) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -// KVStoreDeleteResponse is a structure supplied as a response message to the -// KVStore Delete callback function. -// -// This response is a general response type used for all KVStore types provided -// by Tarmac. -type KVStoreDeleteResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Status is the human readable error message or success message for function - // execution. - Status *Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` -} - -func (x *KVStoreDeleteResponse) Reset() { - *x = KVStoreDeleteResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_kvstore_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *KVStoreDeleteResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*KVStoreDeleteResponse) ProtoMessage() {} - -func (x *KVStoreDeleteResponse) ProtoReflect() protoreflect.Message { - mi := &file_kvstore_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use KVStoreDeleteResponse.ProtoReflect.Descriptor instead. -func (*KVStoreDeleteResponse) Descriptor() ([]byte, []int) { - return file_kvstore_proto_rawDescGZIP(), []int{5} -} - -func (x *KVStoreDeleteResponse) GetStatus() *Status { - if x != nil { - return x.Status - } - return nil -} - -// KVStoreKeys is a structure used to create a Keys callback request to the -// Tarmac KVStore interface. -// -// This structure is a general request type used for all KVStore types provided -// by Tarmac. -type KVStoreKeys struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // ReturnProto is a boolean value that determines if the response should be - // returned as a JSON string or as a KVStoreKeysResponse message. - // - // This must be set to true to return a KVStoreKeysResponse message. - ReturnProto bool `protobuf:"varint,1,opt,name=return_proto,json=returnProto,proto3" json:"return_proto,omitempty"` -} - -func (x *KVStoreKeys) Reset() { - *x = KVStoreKeys{} - if protoimpl.UnsafeEnabled { - mi := &file_kvstore_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *KVStoreKeys) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*KVStoreKeys) ProtoMessage() {} - -func (x *KVStoreKeys) ProtoReflect() protoreflect.Message { - mi := &file_kvstore_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use KVStoreKeys.ProtoReflect.Descriptor instead. -func (*KVStoreKeys) Descriptor() ([]byte, []int) { - return file_kvstore_proto_rawDescGZIP(), []int{6} -} - -func (x *KVStoreKeys) GetReturnProto() bool { - if x != nil { - return x.ReturnProto - } - return false -} - -// KVStoreKeysResponse is a structure supplied as a response message to the -// KVStore Keys callback function. -// -// This response is a general response type used for all KVStore types provided -// by Tarmac. -type KVStoreKeysResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Status is the human readable error message or success message for function - // execution. - Status *Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` - // Keys is a list of keys available within the KV Store. - Keys []string `protobuf:"bytes,2,rep,name=keys,proto3" json:"keys,omitempty"` -} - -func (x *KVStoreKeysResponse) Reset() { - *x = KVStoreKeysResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_kvstore_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *KVStoreKeysResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*KVStoreKeysResponse) ProtoMessage() {} - -func (x *KVStoreKeysResponse) ProtoReflect() protoreflect.Message { - mi := &file_kvstore_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use KVStoreKeysResponse.ProtoReflect.Descriptor instead. -func (*KVStoreKeysResponse) Descriptor() ([]byte, []int) { - return file_kvstore_proto_rawDescGZIP(), []int{7} -} - -func (x *KVStoreKeysResponse) GetStatus() *Status { - if x != nil { - return x.Status - } - return nil -} - -func (x *KVStoreKeysResponse) GetKeys() []string { - if x != nil { - return x.Keys - } - return nil -} - -var File_kvstore_proto protoreflect.FileDescriptor - -var file_kvstore_proto_rawDesc = []byte{ - 0x0a, 0x0d, 0x6b, 0x76, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x0e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x6b, 0x76, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x1a, - 0x0c, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1e, 0x0a, - 0x0a, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x47, 0x65, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x50, 0x0a, - 0x12, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, - 0x32, 0x0a, 0x0a, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x53, 0x65, 0x74, 0x12, 0x10, 0x0a, - 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, - 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x22, 0x3c, 0x0a, 0x12, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x53, 0x65, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x61, 0x72, 0x6d, - 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x22, 0x21, 0x0a, 0x0d, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x22, 0x3f, 0x0a, 0x15, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, - 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, - 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x30, 0x0a, 0x0b, 0x4b, 0x56, 0x53, 0x74, 0x6f, 0x72, 0x65, - 0x4b, 0x65, 0x79, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x5f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x72, 0x65, 0x74, 0x75, - 0x72, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x51, 0x0a, 0x13, 0x4b, 0x56, 0x53, 0x74, 0x6f, - 0x72, 0x65, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, - 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, - 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2d, - 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_kvstore_proto_rawDescOnce sync.Once - file_kvstore_proto_rawDescData = file_kvstore_proto_rawDesc -) - -func file_kvstore_proto_rawDescGZIP() []byte { - file_kvstore_proto_rawDescOnce.Do(func() { - file_kvstore_proto_rawDescData = protoimpl.X.CompressGZIP(file_kvstore_proto_rawDescData) - }) - return file_kvstore_proto_rawDescData -} - -var file_kvstore_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_kvstore_proto_goTypes = []any{ - (*KVStoreGet)(nil), // 0: tarmac.kvstore.KVStoreGet - (*KVStoreGetResponse)(nil), // 1: tarmac.kvstore.KVStoreGetResponse - (*KVStoreSet)(nil), // 2: tarmac.kvstore.KVStoreSet - (*KVStoreSetResponse)(nil), // 3: tarmac.kvstore.KVStoreSetResponse - (*KVStoreDelete)(nil), // 4: tarmac.kvstore.KVStoreDelete - (*KVStoreDeleteResponse)(nil), // 5: tarmac.kvstore.KVStoreDeleteResponse - (*KVStoreKeys)(nil), // 6: tarmac.kvstore.KVStoreKeys - (*KVStoreKeysResponse)(nil), // 7: tarmac.kvstore.KVStoreKeysResponse - (*Status)(nil), // 8: tarmac.Status -} -var file_kvstore_proto_depIdxs = []int32{ - 8, // 0: tarmac.kvstore.KVStoreGetResponse.status:type_name -> tarmac.Status - 8, // 1: tarmac.kvstore.KVStoreSetResponse.status:type_name -> tarmac.Status - 8, // 2: tarmac.kvstore.KVStoreDeleteResponse.status:type_name -> tarmac.Status - 8, // 3: tarmac.kvstore.KVStoreKeysResponse.status:type_name -> tarmac.Status - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name -} - -func init() { file_kvstore_proto_init() } -func file_kvstore_proto_init() { - if File_kvstore_proto != nil { - return - } - file_tarmac_proto_init() - if !protoimpl.UnsafeEnabled { - file_kvstore_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*KVStoreGet); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_kvstore_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*KVStoreGetResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_kvstore_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*KVStoreSet); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_kvstore_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*KVStoreSetResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_kvstore_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*KVStoreDelete); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_kvstore_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*KVStoreDeleteResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_kvstore_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*KVStoreKeys); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_kvstore_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*KVStoreKeysResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_kvstore_proto_rawDesc, - NumEnums: 0, - NumMessages: 8, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_kvstore_proto_goTypes, - DependencyIndexes: file_kvstore_proto_depIdxs, - MessageInfos: file_kvstore_proto_msgTypes, - }.Build() - File_kvstore_proto = out.File - file_kvstore_proto_rawDesc = nil - file_kvstore_proto_goTypes = nil - file_kvstore_proto_depIdxs = nil -} diff --git a/proto/kvstore_vtproto.pb.go b/proto/kvstore_vtproto.pb.go deleted file mode 100644 index 4fb63b3e..00000000 --- a/proto/kvstore_vtproto.pb.go +++ /dev/null @@ -1,2727 +0,0 @@ -// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. -// protoc-gen-go-vtproto version: v0.6.0 -// source: kvstore.proto - -package proto - -import ( - fmt "fmt" - protohelpers "github.com/planetscale/vtprotobuf/protohelpers" - proto "google.golang.org/protobuf/proto" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -func (m *KVStoreGet) CloneVT() *KVStoreGet { - if m == nil { - return (*KVStoreGet)(nil) - } - r := new(KVStoreGet) - r.Key = m.Key - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *KVStoreGet) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (m *KVStoreGetResponse) CloneVT() *KVStoreGetResponse { - if m == nil { - return (*KVStoreGetResponse)(nil) - } - r := new(KVStoreGetResponse) - r.Status = m.Status.CloneVT() - if rhs := m.Data; rhs != nil { - tmpBytes := make([]byte, len(rhs)) - copy(tmpBytes, rhs) - r.Data = tmpBytes - } - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *KVStoreGetResponse) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (m *KVStoreSet) CloneVT() *KVStoreSet { - if m == nil { - return (*KVStoreSet)(nil) - } - r := new(KVStoreSet) - r.Key = m.Key - if rhs := m.Data; rhs != nil { - tmpBytes := make([]byte, len(rhs)) - copy(tmpBytes, rhs) - r.Data = tmpBytes - } - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *KVStoreSet) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (m *KVStoreSetResponse) CloneVT() *KVStoreSetResponse { - if m == nil { - return (*KVStoreSetResponse)(nil) - } - r := new(KVStoreSetResponse) - r.Status = m.Status.CloneVT() - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *KVStoreSetResponse) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (m *KVStoreDelete) CloneVT() *KVStoreDelete { - if m == nil { - return (*KVStoreDelete)(nil) - } - r := new(KVStoreDelete) - r.Key = m.Key - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *KVStoreDelete) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (m *KVStoreDeleteResponse) CloneVT() *KVStoreDeleteResponse { - if m == nil { - return (*KVStoreDeleteResponse)(nil) - } - r := new(KVStoreDeleteResponse) - r.Status = m.Status.CloneVT() - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *KVStoreDeleteResponse) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (m *KVStoreKeys) CloneVT() *KVStoreKeys { - if m == nil { - return (*KVStoreKeys)(nil) - } - r := new(KVStoreKeys) - r.ReturnProto = m.ReturnProto - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *KVStoreKeys) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (m *KVStoreKeysResponse) CloneVT() *KVStoreKeysResponse { - if m == nil { - return (*KVStoreKeysResponse)(nil) - } - r := new(KVStoreKeysResponse) - r.Status = m.Status.CloneVT() - if rhs := m.Keys; rhs != nil { - tmpContainer := make([]string, len(rhs)) - copy(tmpContainer, rhs) - r.Keys = tmpContainer - } - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *KVStoreKeysResponse) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (this *KVStoreGet) EqualVT(that *KVStoreGet) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if this.Key != that.Key { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *KVStoreGet) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*KVStoreGet) - if !ok { - return false - } - return this.EqualVT(that) -} -func (this *KVStoreGetResponse) EqualVT(that *KVStoreGetResponse) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if !this.Status.EqualVT(that.Status) { - return false - } - if string(this.Data) != string(that.Data) { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *KVStoreGetResponse) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*KVStoreGetResponse) - if !ok { - return false - } - return this.EqualVT(that) -} -func (this *KVStoreSet) EqualVT(that *KVStoreSet) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if this.Key != that.Key { - return false - } - if string(this.Data) != string(that.Data) { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *KVStoreSet) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*KVStoreSet) - if !ok { - return false - } - return this.EqualVT(that) -} -func (this *KVStoreSetResponse) EqualVT(that *KVStoreSetResponse) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if !this.Status.EqualVT(that.Status) { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *KVStoreSetResponse) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*KVStoreSetResponse) - if !ok { - return false - } - return this.EqualVT(that) -} -func (this *KVStoreDelete) EqualVT(that *KVStoreDelete) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if this.Key != that.Key { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *KVStoreDelete) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*KVStoreDelete) - if !ok { - return false - } - return this.EqualVT(that) -} -func (this *KVStoreDeleteResponse) EqualVT(that *KVStoreDeleteResponse) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if !this.Status.EqualVT(that.Status) { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *KVStoreDeleteResponse) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*KVStoreDeleteResponse) - if !ok { - return false - } - return this.EqualVT(that) -} -func (this *KVStoreKeys) EqualVT(that *KVStoreKeys) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if this.ReturnProto != that.ReturnProto { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *KVStoreKeys) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*KVStoreKeys) - if !ok { - return false - } - return this.EqualVT(that) -} -func (this *KVStoreKeysResponse) EqualVT(that *KVStoreKeysResponse) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if !this.Status.EqualVT(that.Status) { - return false - } - if len(this.Keys) != len(that.Keys) { - return false - } - for i, vx := range this.Keys { - vy := that.Keys[i] - if vx != vy { - return false - } - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *KVStoreKeysResponse) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*KVStoreKeysResponse) - if !ok { - return false - } - return this.EqualVT(that) -} -func (m *KVStoreGet) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreGet) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *KVStoreGet) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KVStoreGetResponse) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreGetResponse) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *KVStoreGetResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x12 - } - if m.Status != nil { - size, err := m.Status.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KVStoreSet) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreSet) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *KVStoreSet) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x12 - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KVStoreSetResponse) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreSetResponse) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *KVStoreSetResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.Status != nil { - size, err := m.Status.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KVStoreDelete) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreDelete) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *KVStoreDelete) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KVStoreDeleteResponse) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreDeleteResponse) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *KVStoreDeleteResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.Status != nil { - size, err := m.Status.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KVStoreKeys) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreKeys) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *KVStoreKeys) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.ReturnProto { - i-- - if m.ReturnProto { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *KVStoreKeysResponse) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreKeysResponse) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *KVStoreKeysResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Keys) > 0 { - for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Keys[iNdEx]) - copy(dAtA[i:], m.Keys[iNdEx]) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Keys[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if m.Status != nil { - size, err := m.Status.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KVStoreGet) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreGet) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *KVStoreGet) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KVStoreGetResponse) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreGetResponse) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *KVStoreGetResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x12 - } - if m.Status != nil { - size, err := m.Status.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KVStoreSet) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreSet) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *KVStoreSet) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x12 - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KVStoreSetResponse) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreSetResponse) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *KVStoreSetResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.Status != nil { - size, err := m.Status.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KVStoreDelete) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreDelete) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *KVStoreDelete) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KVStoreDeleteResponse) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreDeleteResponse) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *KVStoreDeleteResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.Status != nil { - size, err := m.Status.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KVStoreKeys) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreKeys) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *KVStoreKeys) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.ReturnProto { - i-- - if m.ReturnProto { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *KVStoreKeysResponse) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KVStoreKeysResponse) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *KVStoreKeysResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Keys) > 0 { - for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Keys[iNdEx]) - copy(dAtA[i:], m.Keys[iNdEx]) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Keys[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if m.Status != nil { - size, err := m.Status.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KVStoreGet) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *KVStoreGetResponse) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Status != nil { - l = m.Status.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - l = len(m.Data) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *KVStoreSet) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - l = len(m.Data) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *KVStoreSetResponse) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Status != nil { - l = m.Status.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *KVStoreDelete) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *KVStoreDeleteResponse) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Status != nil { - l = m.Status.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *KVStoreKeys) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ReturnProto { - n += 2 - } - n += len(m.unknownFields) - return n -} - -func (m *KVStoreKeysResponse) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Status != nil { - l = m.Status.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - if len(m.Keys) > 0 { - for _, s := range m.Keys { - l = len(s) - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - } - n += len(m.unknownFields) - return n -} - -func (m *KVStoreGet) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreGet: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreGet: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreGetResponse) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreGetResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreGetResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &Status{} - } - if err := m.Status.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreSet) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreSet: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreSet: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreSetResponse) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreSetResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreSetResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &Status{} - } - if err := m.Status.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreDelete) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreDelete: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreDelete: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreDeleteResponse) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreDeleteResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreDeleteResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &Status{} - } - if err := m.Status.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreKeys) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreKeys: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreKeys: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ReturnProto", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.ReturnProto = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreKeysResponse) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreKeysResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreKeysResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &Status{} - } - if err := m.Status.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Keys = append(m.Keys, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreGet) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreGet: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreGet: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var stringValue string - if intStringLen > 0 { - stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) - } - m.Key = stringValue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreGetResponse) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreGetResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreGetResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &Status{} - } - if err := m.Status.UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = dAtA[iNdEx:postIndex] - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreSet) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreSet: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreSet: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var stringValue string - if intStringLen > 0 { - stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) - } - m.Key = stringValue - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = dAtA[iNdEx:postIndex] - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreSetResponse) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreSetResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreSetResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &Status{} - } - if err := m.Status.UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreDelete) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreDelete: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreDelete: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var stringValue string - if intStringLen > 0 { - stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) - } - m.Key = stringValue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreDeleteResponse) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreDeleteResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreDeleteResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &Status{} - } - if err := m.Status.UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreKeys) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreKeys: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreKeys: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ReturnProto", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.ReturnProto = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KVStoreKeysResponse) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KVStoreKeysResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVStoreKeysResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &Status{} - } - if err := m.Status.UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var stringValue string - if intStringLen > 0 { - stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) - } - m.Keys = append(m.Keys, stringValue) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} diff --git a/proto/metrics.pb.go b/proto/metrics.pb.go deleted file mode 100644 index 70ccd602..00000000 --- a/proto/metrics.pb.go +++ /dev/null @@ -1,300 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.3 -// source: metrics.proto - -package proto - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// MetricsCounter is a structure used to create Counter metrics callback -// requests to the Tarmac Metrics interface. -type MetricsCounter struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Name is the name of the metric as exposed via the metrics HTTP end-point. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *MetricsCounter) Reset() { - *x = MetricsCounter{} - if protoimpl.UnsafeEnabled { - mi := &file_metrics_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MetricsCounter) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MetricsCounter) ProtoMessage() {} - -func (x *MetricsCounter) ProtoReflect() protoreflect.Message { - mi := &file_metrics_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use MetricsCounter.ProtoReflect.Descriptor instead. -func (*MetricsCounter) Descriptor() ([]byte, []int) { - return file_metrics_proto_rawDescGZIP(), []int{0} -} - -func (x *MetricsCounter) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// MetricsGauge is a structure used to create Gauge metrics callback requests -// to the Tarmac Metrics interface. -type MetricsGauge struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Name is the name of the metric as exposed via the metrics HTTP end-point. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // Action is the action to be performed for the Gauge metric. - // Valid options are inc (Increment) and dec (Decrement). - Action string `protobuf:"bytes,2,opt,name=action,proto3" json:"action,omitempty"` // inc or dec -} - -func (x *MetricsGauge) Reset() { - *x = MetricsGauge{} - if protoimpl.UnsafeEnabled { - mi := &file_metrics_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MetricsGauge) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MetricsGauge) ProtoMessage() {} - -func (x *MetricsGauge) ProtoReflect() protoreflect.Message { - mi := &file_metrics_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use MetricsGauge.ProtoReflect.Descriptor instead. -func (*MetricsGauge) Descriptor() ([]byte, []int) { - return file_metrics_proto_rawDescGZIP(), []int{1} -} - -func (x *MetricsGauge) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *MetricsGauge) GetAction() string { - if x != nil { - return x.Action - } - return "" -} - -// MetricsHistogram is a structure used to create Histogram metrics callback -// requests to the Tarmac Metrics interface. -type MetricsHistogram struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Name is the name of the metric as exposed via the metrics HTTP end-point. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // Value is the value to Observe for the Histogram metric. - Value float64 `protobuf:"fixed64,2,opt,name=value,proto3" json:"value,omitempty"` -} - -func (x *MetricsHistogram) Reset() { - *x = MetricsHistogram{} - if protoimpl.UnsafeEnabled { - mi := &file_metrics_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MetricsHistogram) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MetricsHistogram) ProtoMessage() {} - -func (x *MetricsHistogram) ProtoReflect() protoreflect.Message { - mi := &file_metrics_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use MetricsHistogram.ProtoReflect.Descriptor instead. -func (*MetricsHistogram) Descriptor() ([]byte, []int) { - return file_metrics_proto_rawDescGZIP(), []int{2} -} - -func (x *MetricsHistogram) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *MetricsHistogram) GetValue() float64 { - if x != nil { - return x.Value - } - return 0 -} - -var File_metrics_proto protoreflect.FileDescriptor - -var file_metrics_proto_rawDesc = []byte{ - 0x0a, 0x0d, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x0e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x22, - 0x24, 0x0a, 0x0e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, - 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, - 0x47, 0x61, 0x75, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x22, 0x3c, 0x0a, 0x10, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x48, 0x69, 0x73, 0x74, - 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, - 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x61, - 0x72, 0x6d, 0x61, 0x63, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x74, 0x61, 0x72, - 0x6d, 0x61, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, -} - -var ( - file_metrics_proto_rawDescOnce sync.Once - file_metrics_proto_rawDescData = file_metrics_proto_rawDesc -) - -func file_metrics_proto_rawDescGZIP() []byte { - file_metrics_proto_rawDescOnce.Do(func() { - file_metrics_proto_rawDescData = protoimpl.X.CompressGZIP(file_metrics_proto_rawDescData) - }) - return file_metrics_proto_rawDescData -} - -var file_metrics_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_metrics_proto_goTypes = []any{ - (*MetricsCounter)(nil), // 0: tarmac.metrics.MetricsCounter - (*MetricsGauge)(nil), // 1: tarmac.metrics.MetricsGauge - (*MetricsHistogram)(nil), // 2: tarmac.metrics.MetricsHistogram -} -var file_metrics_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_metrics_proto_init() } -func file_metrics_proto_init() { - if File_metrics_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_metrics_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*MetricsCounter); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_metrics_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*MetricsGauge); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_metrics_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*MetricsHistogram); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_metrics_proto_rawDesc, - NumEnums: 0, - NumMessages: 3, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_metrics_proto_goTypes, - DependencyIndexes: file_metrics_proto_depIdxs, - MessageInfos: file_metrics_proto_msgTypes, - }.Build() - File_metrics_proto = out.File - file_metrics_proto_rawDesc = nil - file_metrics_proto_goTypes = nil - file_metrics_proto_depIdxs = nil -} diff --git a/proto/metrics_vtproto.pb.go b/proto/metrics_vtproto.pb.go deleted file mode 100644 index 32297228..00000000 --- a/proto/metrics_vtproto.pb.go +++ /dev/null @@ -1,1055 +0,0 @@ -// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. -// protoc-gen-go-vtproto version: v0.6.0 -// source: metrics.proto - -package proto - -import ( - binary "encoding/binary" - fmt "fmt" - protohelpers "github.com/planetscale/vtprotobuf/protohelpers" - proto "google.golang.org/protobuf/proto" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - math "math" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -func (m *MetricsCounter) CloneVT() *MetricsCounter { - if m == nil { - return (*MetricsCounter)(nil) - } - r := new(MetricsCounter) - r.Name = m.Name - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *MetricsCounter) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (m *MetricsGauge) CloneVT() *MetricsGauge { - if m == nil { - return (*MetricsGauge)(nil) - } - r := new(MetricsGauge) - r.Name = m.Name - r.Action = m.Action - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *MetricsGauge) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (m *MetricsHistogram) CloneVT() *MetricsHistogram { - if m == nil { - return (*MetricsHistogram)(nil) - } - r := new(MetricsHistogram) - r.Name = m.Name - r.Value = m.Value - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *MetricsHistogram) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (this *MetricsCounter) EqualVT(that *MetricsCounter) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if this.Name != that.Name { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *MetricsCounter) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*MetricsCounter) - if !ok { - return false - } - return this.EqualVT(that) -} -func (this *MetricsGauge) EqualVT(that *MetricsGauge) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if this.Name != that.Name { - return false - } - if this.Action != that.Action { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *MetricsGauge) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*MetricsGauge) - if !ok { - return false - } - return this.EqualVT(that) -} -func (this *MetricsHistogram) EqualVT(that *MetricsHistogram) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if this.Name != that.Name { - return false - } - if this.Value != that.Value { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *MetricsHistogram) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*MetricsHistogram) - if !ok { - return false - } - return this.EqualVT(that) -} -func (m *MetricsCounter) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MetricsCounter) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *MetricsCounter) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MetricsGauge) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MetricsGauge) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *MetricsGauge) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Action) > 0 { - i -= len(m.Action) - copy(dAtA[i:], m.Action) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Action))) - i-- - dAtA[i] = 0x12 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MetricsHistogram) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MetricsHistogram) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *MetricsHistogram) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.Value != 0 { - i -= 8 - binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) - i-- - dAtA[i] = 0x11 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MetricsCounter) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MetricsCounter) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *MetricsCounter) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MetricsGauge) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MetricsGauge) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *MetricsGauge) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Action) > 0 { - i -= len(m.Action) - copy(dAtA[i:], m.Action) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Action))) - i-- - dAtA[i] = 0x12 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MetricsHistogram) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MetricsHistogram) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *MetricsHistogram) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.Value != 0 { - i -= 8 - binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) - i-- - dAtA[i] = 0x11 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MetricsCounter) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *MetricsGauge) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - l = len(m.Action) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *MetricsHistogram) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - if m.Value != 0 { - n += 9 - } - n += len(m.unknownFields) - return n -} - -func (m *MetricsCounter) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MetricsCounter: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MetricsCounter: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MetricsGauge) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MetricsGauge: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MetricsGauge: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Action", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Action = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MetricsHistogram) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MetricsHistogram: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MetricsHistogram: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Value = float64(math.Float64frombits(v)) - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MetricsCounter) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MetricsCounter: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MetricsCounter: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var stringValue string - if intStringLen > 0 { - stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) - } - m.Name = stringValue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MetricsGauge) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MetricsGauge: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MetricsGauge: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var stringValue string - if intStringLen > 0 { - stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) - } - m.Name = stringValue - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Action", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var stringValue string - if intStringLen > 0 { - stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) - } - m.Action = stringValue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MetricsHistogram) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MetricsHistogram: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MetricsHistogram: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var stringValue string - if intStringLen > 0 { - stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) - } - m.Name = stringValue - iNdEx = postIndex - case 2: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Value = float64(math.Float64frombits(v)) - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} diff --git a/proto/sql.pb.go b/proto/sql.pb.go deleted file mode 100644 index 65315e1d..00000000 --- a/proto/sql.pb.go +++ /dev/null @@ -1,400 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.3 -// source: sql.proto - -package proto - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// SQLExec is a structure used to execute a SQL query on a SQL Database. -// This message type should be leveraged for queries that do not return rows. -type SQLExec struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Query is the SQL Query to be executed. This field should be a byte slice - // to avoid conflicts with JSON encoding. - Query []byte `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"` -} - -func (x *SQLExec) Reset() { - *x = SQLExec{} - if protoimpl.UnsafeEnabled { - mi := &file_sql_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SQLExec) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SQLExec) ProtoMessage() {} - -func (x *SQLExec) ProtoReflect() protoreflect.Message { - mi := &file_sql_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SQLExec.ProtoReflect.Descriptor instead. -func (*SQLExec) Descriptor() ([]byte, []int) { - return file_sql_proto_rawDescGZIP(), []int{0} -} - -func (x *SQLExec) GetQuery() []byte { - if x != nil { - return x.Query - } - return nil -} - -// SQLExecResponse is a structure supplied as a response message to a SQLExec -// request. -type SQLExecResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Status is the human readable error message or success message for function - // execution. - Status *Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` - // LastInsertID is the ID of the last inserted row. This field is only - // populated if the query was an insert query and the database supports - // returning the last inserted ID. - LastInsertId int64 `protobuf:"varint,2,opt,name=last_insert_id,json=lastInsertId,proto3" json:"last_insert_id,omitempty"` - // RowsAffected is the number of rows affected by the query. This field is - // only populated if the query was an insert, update, or delete query. - RowsAffected int64 `protobuf:"varint,3,opt,name=rows_affected,json=rowsAffected,proto3" json:"rows_affected,omitempty"` -} - -func (x *SQLExecResponse) Reset() { - *x = SQLExecResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_sql_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SQLExecResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SQLExecResponse) ProtoMessage() {} - -func (x *SQLExecResponse) ProtoReflect() protoreflect.Message { - mi := &file_sql_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SQLExecResponse.ProtoReflect.Descriptor instead. -func (*SQLExecResponse) Descriptor() ([]byte, []int) { - return file_sql_proto_rawDescGZIP(), []int{1} -} - -func (x *SQLExecResponse) GetStatus() *Status { - if x != nil { - return x.Status - } - return nil -} - -func (x *SQLExecResponse) GetLastInsertId() int64 { - if x != nil { - return x.LastInsertId - } - return 0 -} - -func (x *SQLExecResponse) GetRowsAffected() int64 { - if x != nil { - return x.RowsAffected - } - return 0 -} - -// SQLQuery is a structure used to create SQL queries to a SQL Database. -type SQLQuery struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Query is the SQL Query to be executed. This field should be a byte slice - // to avoid conflicts with JSON encoding. - Query []byte `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"` -} - -func (x *SQLQuery) Reset() { - *x = SQLQuery{} - if protoimpl.UnsafeEnabled { - mi := &file_sql_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SQLQuery) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SQLQuery) ProtoMessage() {} - -func (x *SQLQuery) ProtoReflect() protoreflect.Message { - mi := &file_sql_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SQLQuery.ProtoReflect.Descriptor instead. -func (*SQLQuery) Descriptor() ([]byte, []int) { - return file_sql_proto_rawDescGZIP(), []int{2} -} - -func (x *SQLQuery) GetQuery() []byte { - if x != nil { - return x.Query - } - return nil -} - -// SQLQueryResponse is a structure supplied as a response message to a SQL -// Database Query. -type SQLQueryResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Status is the human readable error message or success message for function - // execution. - Status *Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` - // Columns is a list of column names returned by the query. This field is - // only populated if the query was a select query. - Columns []string `protobuf:"bytes,4,rep,name=columns,proto3" json:"columns,omitempty"` - // Data is a JSON encoded byte slice of the data returned by the query. - Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` -} - -func (x *SQLQueryResponse) Reset() { - *x = SQLQueryResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_sql_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SQLQueryResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SQLQueryResponse) ProtoMessage() {} - -func (x *SQLQueryResponse) ProtoReflect() protoreflect.Message { - mi := &file_sql_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SQLQueryResponse.ProtoReflect.Descriptor instead. -func (*SQLQueryResponse) Descriptor() ([]byte, []int) { - return file_sql_proto_rawDescGZIP(), []int{3} -} - -func (x *SQLQueryResponse) GetStatus() *Status { - if x != nil { - return x.Status - } - return nil -} - -func (x *SQLQueryResponse) GetColumns() []string { - if x != nil { - return x.Columns - } - return nil -} - -func (x *SQLQueryResponse) GetData() []byte { - if x != nil { - return x.Data - } - return nil -} - -var File_sql_proto protoreflect.FileDescriptor - -var file_sql_proto_rawDesc = []byte{ - 0x0a, 0x09, 0x73, 0x71, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x74, 0x61, 0x72, - 0x6d, 0x61, 0x63, 0x2e, 0x73, 0x71, 0x6c, 0x1a, 0x0c, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1f, 0x0a, 0x07, 0x53, 0x51, 0x4c, 0x45, 0x78, 0x65, 0x63, - 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x22, 0x84, 0x01, 0x0a, 0x0f, 0x53, 0x51, 0x4c, 0x45, 0x78, - 0x65, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x61, 0x72, - 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x69, 0x6e, 0x73, 0x65, 0x72, - 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, - 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x6f, 0x77, 0x73, - 0x5f, 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x0c, 0x72, 0x6f, 0x77, 0x73, 0x41, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x22, 0x20, 0x0a, - 0x08, 0x53, 0x51, 0x4c, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, - 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x22, - 0x68, 0x0a, 0x10, 0x53, 0x51, 0x4c, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, - 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, - 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2d, 0x70, - 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_sql_proto_rawDescOnce sync.Once - file_sql_proto_rawDescData = file_sql_proto_rawDesc -) - -func file_sql_proto_rawDescGZIP() []byte { - file_sql_proto_rawDescOnce.Do(func() { - file_sql_proto_rawDescData = protoimpl.X.CompressGZIP(file_sql_proto_rawDescData) - }) - return file_sql_proto_rawDescData -} - -var file_sql_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_sql_proto_goTypes = []any{ - (*SQLExec)(nil), // 0: tarmac.sql.SQLExec - (*SQLExecResponse)(nil), // 1: tarmac.sql.SQLExecResponse - (*SQLQuery)(nil), // 2: tarmac.sql.SQLQuery - (*SQLQueryResponse)(nil), // 3: tarmac.sql.SQLQueryResponse - (*Status)(nil), // 4: tarmac.Status -} -var file_sql_proto_depIdxs = []int32{ - 4, // 0: tarmac.sql.SQLExecResponse.status:type_name -> tarmac.Status - 4, // 1: tarmac.sql.SQLQueryResponse.status:type_name -> tarmac.Status - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_sql_proto_init() } -func file_sql_proto_init() { - if File_sql_proto != nil { - return - } - file_tarmac_proto_init() - if !protoimpl.UnsafeEnabled { - file_sql_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*SQLExec); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_sql_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*SQLExecResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_sql_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*SQLQuery); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_sql_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*SQLQueryResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_sql_proto_rawDesc, - NumEnums: 0, - NumMessages: 4, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_sql_proto_goTypes, - DependencyIndexes: file_sql_proto_depIdxs, - MessageInfos: file_sql_proto_msgTypes, - }.Build() - File_sql_proto = out.File - file_sql_proto_rawDesc = nil - file_sql_proto_goTypes = nil - file_sql_proto_depIdxs = nil -} diff --git a/proto/sql_vtproto.pb.go b/proto/sql_vtproto.pb.go deleted file mode 100644 index 4a49f393..00000000 --- a/proto/sql_vtproto.pb.go +++ /dev/null @@ -1,1551 +0,0 @@ -// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. -// protoc-gen-go-vtproto version: v0.6.0 -// source: sql.proto - -package proto - -import ( - fmt "fmt" - protohelpers "github.com/planetscale/vtprotobuf/protohelpers" - proto "google.golang.org/protobuf/proto" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -func (m *SQLExec) CloneVT() *SQLExec { - if m == nil { - return (*SQLExec)(nil) - } - r := new(SQLExec) - if rhs := m.Query; rhs != nil { - tmpBytes := make([]byte, len(rhs)) - copy(tmpBytes, rhs) - r.Query = tmpBytes - } - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *SQLExec) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (m *SQLExecResponse) CloneVT() *SQLExecResponse { - if m == nil { - return (*SQLExecResponse)(nil) - } - r := new(SQLExecResponse) - r.Status = m.Status.CloneVT() - r.LastInsertId = m.LastInsertId - r.RowsAffected = m.RowsAffected - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *SQLExecResponse) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (m *SQLQuery) CloneVT() *SQLQuery { - if m == nil { - return (*SQLQuery)(nil) - } - r := new(SQLQuery) - if rhs := m.Query; rhs != nil { - tmpBytes := make([]byte, len(rhs)) - copy(tmpBytes, rhs) - r.Query = tmpBytes - } - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *SQLQuery) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (m *SQLQueryResponse) CloneVT() *SQLQueryResponse { - if m == nil { - return (*SQLQueryResponse)(nil) - } - r := new(SQLQueryResponse) - r.Status = m.Status.CloneVT() - if rhs := m.Columns; rhs != nil { - tmpContainer := make([]string, len(rhs)) - copy(tmpContainer, rhs) - r.Columns = tmpContainer - } - if rhs := m.Data; rhs != nil { - tmpBytes := make([]byte, len(rhs)) - copy(tmpBytes, rhs) - r.Data = tmpBytes - } - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *SQLQueryResponse) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (this *SQLExec) EqualVT(that *SQLExec) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if string(this.Query) != string(that.Query) { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *SQLExec) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*SQLExec) - if !ok { - return false - } - return this.EqualVT(that) -} -func (this *SQLExecResponse) EqualVT(that *SQLExecResponse) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if !this.Status.EqualVT(that.Status) { - return false - } - if this.LastInsertId != that.LastInsertId { - return false - } - if this.RowsAffected != that.RowsAffected { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *SQLExecResponse) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*SQLExecResponse) - if !ok { - return false - } - return this.EqualVT(that) -} -func (this *SQLQuery) EqualVT(that *SQLQuery) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if string(this.Query) != string(that.Query) { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *SQLQuery) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*SQLQuery) - if !ok { - return false - } - return this.EqualVT(that) -} -func (this *SQLQueryResponse) EqualVT(that *SQLQueryResponse) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if !this.Status.EqualVT(that.Status) { - return false - } - if len(this.Columns) != len(that.Columns) { - return false - } - for i, vx := range this.Columns { - vy := that.Columns[i] - if vx != vy { - return false - } - } - if string(this.Data) != string(that.Data) { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *SQLQueryResponse) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*SQLQueryResponse) - if !ok { - return false - } - return this.EqualVT(that) -} -func (m *SQLExec) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SQLExec) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *SQLExec) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Query) > 0 { - i -= len(m.Query) - copy(dAtA[i:], m.Query) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Query))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SQLExecResponse) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SQLExecResponse) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *SQLExecResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.RowsAffected != 0 { - i = protohelpers.EncodeVarint(dAtA, i, uint64(m.RowsAffected)) - i-- - dAtA[i] = 0x18 - } - if m.LastInsertId != 0 { - i = protohelpers.EncodeVarint(dAtA, i, uint64(m.LastInsertId)) - i-- - dAtA[i] = 0x10 - } - if m.Status != nil { - size, err := m.Status.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SQLQuery) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SQLQuery) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *SQLQuery) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Query) > 0 { - i -= len(m.Query) - copy(dAtA[i:], m.Query) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Query))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SQLQueryResponse) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SQLQueryResponse) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *SQLQueryResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x2a - } - if len(m.Columns) > 0 { - for iNdEx := len(m.Columns) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Columns[iNdEx]) - copy(dAtA[i:], m.Columns[iNdEx]) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Columns[iNdEx]))) - i-- - dAtA[i] = 0x22 - } - } - if m.Status != nil { - size, err := m.Status.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SQLExec) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SQLExec) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *SQLExec) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Query) > 0 { - i -= len(m.Query) - copy(dAtA[i:], m.Query) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Query))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SQLExecResponse) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SQLExecResponse) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *SQLExecResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.RowsAffected != 0 { - i = protohelpers.EncodeVarint(dAtA, i, uint64(m.RowsAffected)) - i-- - dAtA[i] = 0x18 - } - if m.LastInsertId != 0 { - i = protohelpers.EncodeVarint(dAtA, i, uint64(m.LastInsertId)) - i-- - dAtA[i] = 0x10 - } - if m.Status != nil { - size, err := m.Status.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SQLQuery) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SQLQuery) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *SQLQuery) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Query) > 0 { - i -= len(m.Query) - copy(dAtA[i:], m.Query) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Query))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SQLQueryResponse) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SQLQueryResponse) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *SQLQueryResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x2a - } - if len(m.Columns) > 0 { - for iNdEx := len(m.Columns) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Columns[iNdEx]) - copy(dAtA[i:], m.Columns[iNdEx]) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Columns[iNdEx]))) - i-- - dAtA[i] = 0x22 - } - } - if m.Status != nil { - size, err := m.Status.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SQLExec) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Query) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *SQLExecResponse) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Status != nil { - l = m.Status.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - if m.LastInsertId != 0 { - n += 1 + protohelpers.SizeOfVarint(uint64(m.LastInsertId)) - } - if m.RowsAffected != 0 { - n += 1 + protohelpers.SizeOfVarint(uint64(m.RowsAffected)) - } - n += len(m.unknownFields) - return n -} - -func (m *SQLQuery) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Query) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *SQLQueryResponse) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Status != nil { - l = m.Status.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - if len(m.Columns) > 0 { - for _, s := range m.Columns { - l = len(s) - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - } - l = len(m.Data) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *SQLExec) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SQLExec: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SQLExec: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Query = append(m.Query[:0], dAtA[iNdEx:postIndex]...) - if m.Query == nil { - m.Query = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SQLExecResponse) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SQLExecResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SQLExecResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &Status{} - } - if err := m.Status.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LastInsertId", wireType) - } - m.LastInsertId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LastInsertId |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RowsAffected", wireType) - } - m.RowsAffected = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RowsAffected |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SQLQuery) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SQLQuery: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SQLQuery: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Query = append(m.Query[:0], dAtA[iNdEx:postIndex]...) - if m.Query == nil { - m.Query = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SQLQueryResponse) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SQLQueryResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SQLQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &Status{} - } - if err := m.Status.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Columns", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Columns = append(m.Columns, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SQLExec) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SQLExec: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SQLExec: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Query = dAtA[iNdEx:postIndex] - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SQLExecResponse) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SQLExecResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SQLExecResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &Status{} - } - if err := m.Status.UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LastInsertId", wireType) - } - m.LastInsertId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LastInsertId |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RowsAffected", wireType) - } - m.RowsAffected = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RowsAffected |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SQLQuery) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SQLQuery: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SQLQuery: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Query = dAtA[iNdEx:postIndex] - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SQLQueryResponse) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SQLQueryResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SQLQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &Status{} - } - if err := m.Status.UnmarshalVTUnsafe(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Columns", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var stringValue string - if intStringLen > 0 { - stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) - } - m.Columns = append(m.Columns, stringValue) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = dAtA[iNdEx:postIndex] - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} diff --git a/proto/tarmac.pb.go b/proto/tarmac.pb.go deleted file mode 100644 index aabbf866..00000000 --- a/proto/tarmac.pb.go +++ /dev/null @@ -1,163 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.3 -// source: tarmac.proto - -package proto - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// Status is used to return a status code and message to clients when -// performing host callbacks to Tarmac. -// -// The status code will indicate failure or success. -// -// Status codes are as follows: -// 000 - Success -// 100 - Failure -type Status struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Code is the status code for callback execution. - Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` - // Status is the human readable error message or success message for function - // execution. - Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` -} - -func (x *Status) Reset() { - *x = Status{} - if protoimpl.UnsafeEnabled { - mi := &file_tarmac_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Status) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Status) ProtoMessage() {} - -func (x *Status) ProtoReflect() protoreflect.Message { - mi := &file_tarmac_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Status.ProtoReflect.Descriptor instead. -func (*Status) Descriptor() ([]byte, []int) { - return file_tarmac_proto_rawDescGZIP(), []int{0} -} - -func (x *Status) GetCode() int32 { - if x != nil { - return x.Code - } - return 0 -} - -func (x *Status) GetStatus() string { - if x != nil { - return x.Status - } - return "" -} - -var File_tarmac_proto protoreflect.FileDescriptor - -var file_tarmac_proto_rawDesc = []byte{ - 0x0a, 0x0c, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, - 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, 0x22, 0x34, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, - 0x63, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x28, 0x5a, 0x26, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, - 0x63, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x74, 0x61, 0x72, 0x6d, 0x61, 0x63, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_tarmac_proto_rawDescOnce sync.Once - file_tarmac_proto_rawDescData = file_tarmac_proto_rawDesc -) - -func file_tarmac_proto_rawDescGZIP() []byte { - file_tarmac_proto_rawDescOnce.Do(func() { - file_tarmac_proto_rawDescData = protoimpl.X.CompressGZIP(file_tarmac_proto_rawDescData) - }) - return file_tarmac_proto_rawDescData -} - -var file_tarmac_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_tarmac_proto_goTypes = []any{ - (*Status)(nil), // 0: tarmac.Status -} -var file_tarmac_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_tarmac_proto_init() } -func file_tarmac_proto_init() { - if File_tarmac_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_tarmac_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Status); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_tarmac_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_tarmac_proto_goTypes, - DependencyIndexes: file_tarmac_proto_depIdxs, - MessageInfos: file_tarmac_proto_msgTypes, - }.Build() - File_tarmac_proto = out.File - file_tarmac_proto_rawDesc = nil - file_tarmac_proto_goTypes = nil - file_tarmac_proto_depIdxs = nil -} diff --git a/proto/tarmac_vtproto.pb.go b/proto/tarmac_vtproto.pb.go deleted file mode 100644 index 4210f993..00000000 --- a/proto/tarmac_vtproto.pb.go +++ /dev/null @@ -1,377 +0,0 @@ -// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. -// protoc-gen-go-vtproto version: v0.6.0 -// source: tarmac.proto - -package proto - -import ( - fmt "fmt" - protohelpers "github.com/planetscale/vtprotobuf/protohelpers" - proto "google.golang.org/protobuf/proto" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -func (m *Status) CloneVT() *Status { - if m == nil { - return (*Status)(nil) - } - r := new(Status) - r.Code = m.Code - r.Status = m.Status - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *Status) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (this *Status) EqualVT(that *Status) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if this.Code != that.Code { - return false - } - if this.Status != that.Status { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *Status) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*Status) - if !ok { - return false - } - return this.EqualVT(that) -} -func (m *Status) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Status) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Status) > 0 { - i -= len(m.Status) - copy(dAtA[i:], m.Status) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Status))) - i-- - dAtA[i] = 0x12 - } - if m.Code != 0 { - i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Code)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Status) MarshalVTStrict() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Status) MarshalToVTStrict(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVTStrict(dAtA[:size]) -} - -func (m *Status) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Status) > 0 { - i -= len(m.Status) - copy(dAtA[i:], m.Status) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Status))) - i-- - dAtA[i] = 0x12 - } - if m.Code != 0 { - i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Code)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Status) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Code != 0 { - n += 1 + protohelpers.SizeOfVarint(uint64(m.Code)) - } - l = len(m.Status) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *Status) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Status: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Status: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) - } - m.Code = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Code |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Status = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Status) UnmarshalVTUnsafe(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Status: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Status: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) - } - m.Code = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Code |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var stringValue string - if intStringLen > 0 { - stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) - } - m.Status = stringValue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} From c9e450a6e0f37f3274a5a86fcbc231515976174f Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 6 Oct 2024 16:01:19 -0700 Subject: [PATCH 15/31] fix(httpclient): correct method receiver name typo Renamed `he` to `hc` because even receivers deserve a little consistency in life, and we all know it's nice to be called by the right name. --- pkg/callbacks/httpclient/httpclient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/callbacks/httpclient/httpclient.go b/pkg/callbacks/httpclient/httpclient.go index 9de27a6e..8b95a24d 100644 --- a/pkg/callbacks/httpclient/httpclient.go +++ b/pkg/callbacks/httpclient/httpclient.go @@ -125,7 +125,7 @@ func (hc *HTTPClient) Call(b []byte) ([]byte, error) { return rsp, fmt.Errorf("%s", r.Status.Status) } -func (he *HTTPClient) callJSON(b []byte) ([]byte, error) { +func (hc *HTTPClient) callJSON(b []byte) ([]byte, error) { // Start Response Message assuming everything is good r := tarmac.HTTPClientResponse{} r.Status.Code = 200 From ce2c1cb8288563715fe9a9b09b1a7e70ce78abec Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 6 Oct 2024 16:40:49 -0700 Subject: [PATCH 16/31] fix(tests): improve error messages for clarity Fine-tuning error messages for a sprinkle of precision. After all, it's better to know a number rather than guess at a mystery wrapped in a test failure. --- pkg/callbacks/httpclient/httpclient_test.go | 9 +++++---- pkg/callbacks/kvstore/kvstore.go | 2 +- pkg/callbacks/kvstore/kvstore_test.go | 10 +++++----- pkg/callbacks/sql/sql.go | 4 ++-- pkg/callbacks/sql/sql_test.go | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/pkg/callbacks/httpclient/httpclient_test.go b/pkg/callbacks/httpclient/httpclient_test.go index 8586fdd8..e26ab586 100644 --- a/pkg/callbacks/httpclient/httpclient_test.go +++ b/pkg/callbacks/httpclient/httpclient_test.go @@ -297,23 +297,24 @@ func Test(t *testing.T) { // Tarmac Response if rsp.Status.Code == 200 && !c.pass { - t.Fatalf(" Callback Set returned an unexpected success - %+v", rsp) + t.Fatalf(" Callback Set returned an unexpected success - %d", rsp.Status.Code) } if rsp.Status.Code != 200 && c.pass { - t.Fatalf(" Callback Set returned an unexpected failure - %+v", rsp) + t.Fatalf(" Callback Set returned an unexpected failure - %d", rsp.Status.Code) + } // HTTP Response if rsp.Code != int32(c.httpCode) { - t.Fatalf(" returned an unexpected response code - %+v", rsp) + t.Fatalf(" returned an unexpected response code - %d", rsp.Code) return } // Validate Response Header v, ok := rsp.Headers["server"] if (!ok || v != "tarmac") && rsp.Code == 200 { - t.Errorf(" returned an unexpected header - %+v", rsp) + t.Errorf(" returned an unexpected header - %s", v) } // Validate Payload diff --git a/pkg/callbacks/kvstore/kvstore.go b/pkg/callbacks/kvstore/kvstore.go index 49c285a5..ca961bcd 100644 --- a/pkg/callbacks/kvstore/kvstore.go +++ b/pkg/callbacks/kvstore/kvstore.go @@ -346,7 +346,7 @@ func (k *KVStore) Keys(b []byte) ([]byte, error) { return m, fmt.Errorf("%s", rsp.Status.Status) } -func (k *KVStore) keysJSON(b []byte) ([]byte, error) { +func (k *KVStore) keysJSON(_ []byte) ([]byte, error) { // Start Response Message assuming everything is good r := tarmac.KVStoreKeysResponse{} r.Status.Code = 200 diff --git a/pkg/callbacks/kvstore/kvstore_test.go b/pkg/callbacks/kvstore/kvstore_test.go index fab3aae2..8941d005 100644 --- a/pkg/callbacks/kvstore/kvstore_test.go +++ b/pkg/callbacks/kvstore/kvstore_test.go @@ -96,11 +96,11 @@ func TestKVStore(t *testing.T) { } if (response.Status.Code == 200) != c.pass { - t.Fatalf("Unexpected response status: %+v", response) + t.Fatalf("Unexpected response status: %d", response.Status.Code) } if c.pass && !bytes.Equal(response.Data, c.value) { - t.Fatalf("Unexpected response data: %+v", response) + t.Fatalf("Unexpected response data: %v", response.Data) } }) } @@ -180,7 +180,7 @@ func TestKVStore(t *testing.T) { } if (response.Status.Code == 200) != c.pass { - t.Fatalf("Unexpected response status: %+v", response) + t.Fatalf("Unexpected response status: %d", response.Status.Code) } }) } @@ -243,7 +243,7 @@ func TestKVStore(t *testing.T) { } if (response.Status.Code == 200) != c.pass { - t.Fatalf("Unexpected response status: %+v", response) + t.Fatalf("Unexpected response status: %d", response.Status.Code) } }) } @@ -332,7 +332,7 @@ func TestKVStore(t *testing.T) { } if (response.Status.Code == 200) != c.pass { - t.Fatalf("Unexpected response status: %+v", response) + t.Fatalf("Unexpected response status: %d", response.Status.Code) } }) } diff --git a/pkg/callbacks/sql/sql.go b/pkg/callbacks/sql/sql.go index 1a1b939a..a14f08d6 100644 --- a/pkg/callbacks/sql/sql.go +++ b/pkg/callbacks/sql/sql.go @@ -230,7 +230,7 @@ func (db *Database) queryJSON(b []byte) ([]byte, error) { // and the values are the column values. func (db *Database) query(qry []byte) ([]string, []map[string]any, error) { - rows, err := db.db.Query(fmt.Sprintf("%s", qry)) + rows, err := db.db.Query(string(qry)) if err != nil { return nil, nil, fmt.Errorf("unable to execute query - %s", err) } @@ -272,5 +272,5 @@ func (db *Database) query(qry []byte) ([]string, []map[string]any, error) { // exec will execute the supplied query against the database and return the result. func (db *Database) exec(qry []byte) (sql.Result, error) { - return db.db.Exec(fmt.Sprintf("%s", qry)) + return db.db.Exec(string(qry)) } diff --git a/pkg/callbacks/sql/sql_test.go b/pkg/callbacks/sql/sql_test.go index 6e71aa69..df797dff 100644 --- a/pkg/callbacks/sql/sql_test.go +++ b/pkg/callbacks/sql/sql_test.go @@ -90,7 +90,7 @@ func TestSQLQuery(t *testing.T) { // Check Status Codes if rsp.Status.Code == 200 { - t.Fatalf("Unexpected Success with unhappy path test - %v", rsp) + t.Fatalf("Unexpected Success with unhappy path test - %d", rsp.Status.Code) } }) } From ec05d68d55ce40ab950719265b237bd90800a500 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 6 Oct 2024 16:44:52 -0700 Subject: [PATCH 17/31] fix(kvstore): anonymize unused parameters Refactored test functions to ignore redundant params. Now, who needs names anyway when you're just a "_"? --- pkg/callbacks/kvstore/kvstore_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/callbacks/kvstore/kvstore_test.go b/pkg/callbacks/kvstore/kvstore_test.go index 8941d005..7c8ee70c 100644 --- a/pkg/callbacks/kvstore/kvstore_test.go +++ b/pkg/callbacks/kvstore/kvstore_test.go @@ -44,7 +44,7 @@ func TestKVStore(t *testing.T) { key: "", value: []byte(""), mockCfg: mock.Config{ - GetFunc: func(key string) ([]byte, error) { + GetFunc: func(_ string) ([]byte, error) { return nil, fmt.Errorf("Key not found") }, }, @@ -116,7 +116,7 @@ func TestKVStore(t *testing.T) { key: "no-data", value: []byte(""), mockCfg: mock.Config{ - SetFunc: func(key string, data []byte) error { + SetFunc: func(_ string, _ []byte) error { return nil }, }, @@ -128,7 +128,7 @@ func TestKVStore(t *testing.T) { key: "", value: []byte("some data"), mockCfg: mock.Config{ - SetFunc: func(key string, data []byte) error { + SetFunc: func(_ string, _ []byte) error { return nil }, }, From 7b346e04cba6316864732377712aecefa0ad9776 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 6 Oct 2024 16:54:21 -0700 Subject: [PATCH 18/31] fix(kvstore): anonymize unused parameter Refactored the test function to ignore the key param. Who needs names when you're just getting deleted anyway? --- pkg/callbacks/kvstore/kvstore_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/callbacks/kvstore/kvstore_test.go b/pkg/callbacks/kvstore/kvstore_test.go index 7c8ee70c..4cd7a5a7 100644 --- a/pkg/callbacks/kvstore/kvstore_test.go +++ b/pkg/callbacks/kvstore/kvstore_test.go @@ -196,7 +196,7 @@ func TestKVStore(t *testing.T) { key: "", value: []byte(""), mockCfg: mock.Config{ - DeleteFunc: func(key string) error { + DeleteFunc: func(_ string) error { return nil }, }, From f1053c0454dff8fb19bb028b0debdbd55b487f9c Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sat, 12 Oct 2024 14:11:45 -0700 Subject: [PATCH 19/31] fix(httpclient): marshal response on request failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gave our HTTP client some empathy—now it not only fails, but also politely explains itself. --- pkg/callbacks/httpclient/httpclient.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/callbacks/httpclient/httpclient.go b/pkg/callbacks/httpclient/httpclient.go index 8b95a24d..b6376ee5 100644 --- a/pkg/callbacks/httpclient/httpclient.go +++ b/pkg/callbacks/httpclient/httpclient.go @@ -82,6 +82,12 @@ func (hc *HTTPClient) Call(b []byte) ([]byte, error) { if err != nil { r.Status.Code = 400 r.Status.Status = fmt.Sprintf("Unable to create HTTP request - %s", err) + // Marshal a response to return to caller + rsp, err := pb.Marshal(r) + if err != nil { + return []byte(""), fmt.Errorf("unable to marshal HTTPClient:call response") + } + return rsp, fmt.Errorf("%s", r.Status.Status) } // Set user-supplied headers @@ -94,6 +100,12 @@ func (hc *HTTPClient) Call(b []byte) ([]byte, error) { if err != nil { r.Status.Code = 500 r.Status.Status = fmt.Sprintf("Unable to execute HTTP request - %s", err) + // Marshal a response to return to caller + rsp, err := pb.Marshal(r) + if err != nil { + return []byte(""), fmt.Errorf("unable to marshal HTTPClient:call response") + } + return rsp, fmt.Errorf("%s", r.Status.Status) } // Populate Response with Response From 4c59b775e4aa0caae3dc96c2e9f2eb4a9586e39b Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 13 Oct 2024 07:59:18 -0700 Subject: [PATCH 20/31] refactor(tests): relocate testdata to new structure Just moved some stuff around to keep the testdata more organized. When a single directory just can't handle the fame, split it! --- Makefile | 17 +++-- pkg/app/app_test.go | 12 ++-- pkg/app/server_test.go | 33 +++++++-- pkg/wasm/wasm_test.go | 10 +-- testdata/{ => base}/default/Makefile | 0 .../{ => base}/default/docker-compose.yml | 0 testdata/{ => base}/default/go.mod | 0 testdata/{ => base}/default/go.sum | 0 testdata/{ => base}/default/main.go | 0 testdata/{ => base}/fail/Makefile | 0 testdata/{ => base}/fail/docker-compose.yml | 0 testdata/{ => base}/fail/go.mod | 0 testdata/{ => base}/fail/go.sum | 0 testdata/{ => base}/fail/main.go | 0 testdata/{ => base}/function/Makefile | 0 .../{ => base}/function/docker-compose.yml | 0 testdata/{ => base}/function/go.mod | 0 testdata/{ => base}/function/go.sum | 0 testdata/{ => base}/function/main.go | 0 testdata/{ => base}/kv/Makefile | 0 testdata/{ => base}/kv/docker-compose.yml | 0 testdata/{ => base}/kv/go.mod | 0 testdata/{ => base}/kv/go.sum | 0 testdata/{ => base}/kv/main.go | 0 testdata/{ => base}/logger/Makefile | 0 testdata/{ => base}/logger/docker-compose.yml | 0 testdata/{ => base}/logger/go.mod | 0 testdata/{ => base}/logger/go.sum | 0 testdata/{ => base}/logger/main.go | 0 testdata/{ => base}/sql/Makefile | 0 testdata/{ => base}/sql/docker-compose.yml | 0 testdata/{ => base}/sql/go.mod | 0 testdata/{ => base}/sql/go.sum | 0 testdata/{ => base}/sql/main.go | 0 testdata/{ => base}/successafter5/Makefile | 0 .../successafter5/docker-compose.yml | 0 testdata/{ => base}/successafter5/go.mod | 0 testdata/{ => base}/successafter5/go.sum | 0 testdata/{ => base}/successafter5/main.go | 0 testdata/sdkv1/kv/Makefile | 10 +++ testdata/sdkv1/kv/docker-compose.yml | 12 ++++ testdata/sdkv1/kv/go.mod | 10 +++ testdata/sdkv1/kv/go.sum | 8 +++ testdata/sdkv1/kv/main.go | 43 +++++++++++ testdata/sdkv1/logger/Makefile | 10 +++ testdata/sdkv1/logger/docker-compose.yml | 12 ++++ testdata/sdkv1/logger/go.mod | 10 +++ testdata/sdkv1/logger/go.sum | 7 ++ testdata/sdkv1/logger/main.go | 28 ++++++++ testdata/sdkv1/sql/Makefile | 10 +++ testdata/sdkv1/sql/docker-compose.yml | 12 ++++ testdata/sdkv1/sql/go.mod | 10 +++ testdata/sdkv1/sql/go.sum | 7 ++ testdata/sdkv1/sql/main.go | 32 +++++++++ testdata/sdkv1/tarmac.json | 72 +++++++++++++++++++ testdata/tarmac-fail.json | 2 +- testdata/tarmac.json | 10 +-- 57 files changed, 346 insertions(+), 31 deletions(-) rename testdata/{ => base}/default/Makefile (100%) rename testdata/{ => base}/default/docker-compose.yml (100%) rename testdata/{ => base}/default/go.mod (100%) rename testdata/{ => base}/default/go.sum (100%) rename testdata/{ => base}/default/main.go (100%) rename testdata/{ => base}/fail/Makefile (100%) rename testdata/{ => base}/fail/docker-compose.yml (100%) rename testdata/{ => base}/fail/go.mod (100%) rename testdata/{ => base}/fail/go.sum (100%) rename testdata/{ => base}/fail/main.go (100%) rename testdata/{ => base}/function/Makefile (100%) rename testdata/{ => base}/function/docker-compose.yml (100%) rename testdata/{ => base}/function/go.mod (100%) rename testdata/{ => base}/function/go.sum (100%) rename testdata/{ => base}/function/main.go (100%) rename testdata/{ => base}/kv/Makefile (100%) rename testdata/{ => base}/kv/docker-compose.yml (100%) rename testdata/{ => base}/kv/go.mod (100%) rename testdata/{ => base}/kv/go.sum (100%) rename testdata/{ => base}/kv/main.go (100%) rename testdata/{ => base}/logger/Makefile (100%) rename testdata/{ => base}/logger/docker-compose.yml (100%) rename testdata/{ => base}/logger/go.mod (100%) rename testdata/{ => base}/logger/go.sum (100%) rename testdata/{ => base}/logger/main.go (100%) rename testdata/{ => base}/sql/Makefile (100%) rename testdata/{ => base}/sql/docker-compose.yml (100%) rename testdata/{ => base}/sql/go.mod (100%) rename testdata/{ => base}/sql/go.sum (100%) rename testdata/{ => base}/sql/main.go (100%) rename testdata/{ => base}/successafter5/Makefile (100%) rename testdata/{ => base}/successafter5/docker-compose.yml (100%) rename testdata/{ => base}/successafter5/go.mod (100%) rename testdata/{ => base}/successafter5/go.sum (100%) rename testdata/{ => base}/successafter5/main.go (100%) create mode 100644 testdata/sdkv1/kv/Makefile create mode 100644 testdata/sdkv1/kv/docker-compose.yml create mode 100644 testdata/sdkv1/kv/go.mod create mode 100644 testdata/sdkv1/kv/go.sum create mode 100644 testdata/sdkv1/kv/main.go create mode 100644 testdata/sdkv1/logger/Makefile create mode 100644 testdata/sdkv1/logger/docker-compose.yml create mode 100644 testdata/sdkv1/logger/go.mod create mode 100644 testdata/sdkv1/logger/go.sum create mode 100644 testdata/sdkv1/logger/main.go create mode 100644 testdata/sdkv1/sql/Makefile create mode 100644 testdata/sdkv1/sql/docker-compose.yml create mode 100644 testdata/sdkv1/sql/go.mod create mode 100644 testdata/sdkv1/sql/go.sum create mode 100644 testdata/sdkv1/sql/main.go create mode 100644 testdata/sdkv1/tarmac.json diff --git a/Makefile b/Makefile index b77c9905..dd07468e 100644 --- a/Makefile +++ b/Makefile @@ -4,13 +4,16 @@ build: build-testdata build-testdata: - $(MAKE) -C testdata/default build - $(MAKE) -C testdata/fail build - $(MAKE) -C testdata/kv build - $(MAKE) -C testdata/sql build - $(MAKE) -C testdata/logger build - $(MAKE) -C testdata/function build - $(MAKE) -C testdata/successafter5 build + $(MAKE) -C testdata/sdkv1/kv build + $(MAKE) -C testdata/sdkv1/sql build + $(MAKE) -C testdata/sdkv1/logger build + $(MAKE) -C testdata/base/default build + $(MAKE) -C testdata/base/fail build + $(MAKE) -C testdata/base/kv build + $(MAKE) -C testdata/base/sql build + $(MAKE) -C testdata/base/logger build + $(MAKE) -C testdata/base/function build + $(MAKE) -C testdata/base/successafter5 build tests: build tests-nobuild tests-nobuild: tests-base tests-redis tests-cassandra tests-mysql tests-postgres tests-boltdb tests-inmemory diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go index 4371edc9..17291102 100644 --- a/pkg/app/app_test.go +++ b/pkg/app/app_test.go @@ -127,7 +127,7 @@ func TestRunningServer(t *testing.T) { cfg.Set("use_consul", false) cfg.Set("debug", true) cfg.Set("trace", true) - cfg.Set("wasm_function", "/testdata/default/tarmac.wasm") + cfg.Set("wasm_function", "/testdata/base/default/tarmac.wasm") srv := New(cfg) go func() { err := srv.Run() @@ -173,7 +173,7 @@ func TestPProfServerEnabled(t *testing.T) { cfg.Set("debug", true) cfg.Set("trace", true) cfg.Set("enable_pprof", true) - cfg.Set("wasm_function", "/testdata/default/tarmac.wasm") + cfg.Set("wasm_function", "/testdata/base/default/tarmac.wasm") srv := New(cfg) go func() { err := srv.Run() @@ -221,7 +221,7 @@ func TestPProfServerDisabled(t *testing.T) { cfg.Set("use_consul", false) cfg.Set("debug", true) cfg.Set("trace", true) - cfg.Set("wasm_function", "/testdata/default/tarmac.wasm") + cfg.Set("wasm_function", "/testdata/base/default/tarmac.wasm") srv := New(cfg) go func() { err := srv.Run() @@ -291,7 +291,7 @@ func TestRunningTLSServer(t *testing.T) { cfg.Set("enable_sql", true) cfg.Set("sql_type", "mysql") cfg.Set("sql_dsn", "root:example@tcp(mysql:3306)/example") - cfg.Set("wasm_function", "/testdata/default/tarmac.wasm") + cfg.Set("wasm_function", "/testdata/base/default/tarmac.wasm") err = cfg.AddRemoteProvider("consul", "consul:8500", "tarmac/config") if err != nil { t.Fatalf("Failed to create Consul config provider - %s", err) @@ -400,7 +400,7 @@ func TestRunningMTLSServer(t *testing.T) { cfg.Set("enable_sql", true) cfg.Set("sql_type", "mysql") cfg.Set("sql_dsn", "root:example@tcp(mysql:3306)/example") - cfg.Set("wasm_function", "/testdata/default/tarmac.wasm") + cfg.Set("wasm_function", "/testdata/base/default/tarmac.wasm") err = cfg.AddRemoteProvider("consul", "consul:8500", "tarmac/config") if err != nil { t.Fatalf("Failed to create Consul config provider - %s", err) @@ -504,7 +504,7 @@ func TestRunningFailMTLSServer(t *testing.T) { cfg.Set("enable_sql", true) cfg.Set("sql_type", "mysql") cfg.Set("sql_dsn", "root:example@tcp(mysql:3306)/example") - cfg.Set("wasm_function", "/testdata/default/tarmac.wasm") + cfg.Set("wasm_function", "/testdata/base/default/tarmac.wasm") err = cfg.AddRemoteProvider("consul", "consul:8500", "tarmac/config") if err != nil { t.Fatalf("Failed to create Consul config provider - %s", err) diff --git a/pkg/app/server_test.go b/pkg/app/server_test.go index 82fd502b..c6d95716 100644 --- a/pkg/app/server_test.go +++ b/pkg/app/server_test.go @@ -26,7 +26,7 @@ func TestBasicFunction(t *testing.T) { cfg.Set("disable_logging", false) cfg.Set("debug", true) cfg.Set("listen_addr", "localhost:9001") - cfg.Set("wasm_function", "/testdata/default/tarmac.wasm") + cfg.Set("wasm_function", "/testdata/base/default/tarmac.wasm") srv := New(cfg) go func() { @@ -95,7 +95,7 @@ func TestMaintenanceMode(t *testing.T) { cfg.Set("disable_logging", false) cfg.Set("debug", true) cfg.Set("listen_addr", "localhost:9001") - cfg.Set("wasm_function", "/testdata/default/tarmac.wasm") + cfg.Set("wasm_function", "/testdata/base/default/tarmac.wasm") cfg.Set("enable_maintenance_mode", true) srv := New(cfg) @@ -200,6 +200,25 @@ func TestFullService(t *testing.T) { tc.cfg.Set("wasm_function_config", "/testdata/tarmac.json") tt = append(tt, tc) + tc = FullServiceTestCase{name: "In-Memory SDKv1", cfg: viper.New()} + tc.cfg.Set("disable_logging", false) + tc.cfg.Set("debug", true) + tc.cfg.Set("listen_addr", "localhost:9001") + tc.cfg.Set("kvstore_type", "in-memory") + tc.cfg.Set("enable_kvstore", true) + tc.cfg.Set("wasm_function_config", "/testdata/sdkv1/tarmac.json") + tt = append(tt, tc) + + tc = FullServiceTestCase{name: "MySQL SDKv1", cfg: viper.New()} + tc.cfg.Set("disable_logging", false) + tc.cfg.Set("debug", true) + tc.cfg.Set("listen_addr", "localhost:9001") + tc.cfg.Set("enable_sql", true) + tc.cfg.Set("sql_type", "mysql") + tc.cfg.Set("sql_dsn", "root:example@tcp(mysql:3306)/example") + tc.cfg.Set("wasm_function_config", "/testdata/sdkv1/tarmac.json") + tt = append(tt, tc) + for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { srv := New(tc.cfg) @@ -292,7 +311,7 @@ func TestInitFuncs(t *testing.T) { tc.cfg.Set("kvstore_type", "in-memory") tc.cfg.Set("enable_kvstore", true) tc.cfg.Set("run_mode", "job") - tc.config = []byte(`{"services":{"test-service":{"name":"test-service","functions":{"default":{"filepath":"/testdata/default/tarmac.wasm","pool_size":1}},"routes":[{"type":"init","function":"default"}]}}}`) + tc.config = []byte(`{"services":{"test-service":{"name":"test-service","functions":{"default":{"filepath":"/testdata/base/default/tarmac.wasm","pool_size":1}},"routes":[{"type":"init","function":"default"}]}}}`) tt = append(tt, tc) tc = InitFuncTestCase{name: "Fails", cfg: viper.New()} @@ -302,7 +321,7 @@ func TestInitFuncs(t *testing.T) { tc.cfg.Set("kvstore_type", "in-memory") tc.cfg.Set("enable_kvstore", true) tc.cfg.Set("run_mode", "job") - tc.config = []byte(`{"services":{"test-service":{"name":"test-service","functions":{"fail":{"filepath":"/testdata/fail/tarmac.wasm","pool_size":1}},"routes":[{"type":"init","function":"fail"}]}}}`) + tc.config = []byte(`{"services":{"test-service":{"name":"test-service","functions":{"fail":{"filepath":"/testdata/base/fail/tarmac.wasm","pool_size":1}},"routes":[{"type":"init","function":"fail"}]}}}`) tc.err = true tt = append(tt, tc) @@ -313,7 +332,7 @@ func TestInitFuncs(t *testing.T) { tc.cfg.Set("kvstore_type", "in-memory") tc.cfg.Set("enable_kvstore", true) tc.cfg.Set("run_mode", "job") - tc.config = []byte(`{"services":{"test-service":{"name":"test-service","functions":{"successafter5":{"filepath":"/testdata/successafter5/tarmac.wasm","pool_size":1}},"routes":[{"type":"init","retries":10,"function":"successafter5"}]}}}`) + tc.config = []byte(`{"services":{"test-service":{"name":"test-service","functions":{"successafter5":{"filepath":"/testdata/base/successafter5/tarmac.wasm","pool_size":1}},"routes":[{"type":"init","retries":10,"function":"successafter5"}]}}}`) tt = append(tt, tc) tc = InitFuncTestCase{name: "Fail After 10 Retries", cfg: viper.New()} @@ -323,7 +342,7 @@ func TestInitFuncs(t *testing.T) { tc.cfg.Set("kvstore_type", "in-memory") tc.cfg.Set("enable_kvstore", true) tc.cfg.Set("run_mode", "job") - tc.config = []byte(`{"services":{"test-service":{"name":"test-service","functions":{"fail":{"filepath":"/testdata/fail/tarmac.wasm","pool_size":1}},"routes":[{"type":"init","retries":10,"function":"fail"}]}}}`) + tc.config = []byte(`{"services":{"test-service":{"name":"test-service","functions":{"fail":{"filepath":"/testdata/base/fail/tarmac.wasm","pool_size":1}},"routes":[{"type":"init","retries":10,"function":"fail"}]}}}`) tc.err = true tt = append(tt, tc) @@ -381,7 +400,7 @@ func TestWASMRunner(t *testing.T) { cfg.Set("disable_logging", false) cfg.Set("debug", true) cfg.Set("listen_addr", "localhost:9001") - cfg.Set("wasm_function", "/testdata/default/tarmac.wasm") + cfg.Set("wasm_function", "/testdata/base/default/tarmac.wasm") srv := New(cfg) go func() { err := srv.Run() diff --git a/pkg/wasm/wasm_test.go b/pkg/wasm/wasm_test.go index 98d7f28f..e909f810 100644 --- a/pkg/wasm/wasm_test.go +++ b/pkg/wasm/wasm_test.go @@ -37,7 +37,7 @@ func TestWASMModuleCreation(t *testing.T) { ModuleConf: ModuleConfig{ Name: "A Module", PoolSize: 99, - Filepath: "/testdata/logger/tarmac.wasm", + Filepath: "/testdata/base/logger/tarmac.wasm", }, }) @@ -47,7 +47,7 @@ func TestWASMModuleCreation(t *testing.T) { Pass: false, ModuleConf: ModuleConfig{ PoolSize: 99, - Filepath: "/testdata/logger/tarmac.wasm", + Filepath: "/testdata/base/logger/tarmac.wasm", }, }) @@ -57,7 +57,7 @@ func TestWASMModuleCreation(t *testing.T) { Pass: true, ModuleConf: ModuleConfig{ Name: "A Module", - Filepath: "/testdata/logger/tarmac.wasm", + Filepath: "/testdata/base/logger/tarmac.wasm", }, }) @@ -78,7 +78,7 @@ func TestWASMModuleCreation(t *testing.T) { ModuleConf: ModuleConfig{ Name: "A Module", PoolSize: 99, - Filepath: "/doesntexist/testdata/logger/tarmac.wasm", + Filepath: "/doesntexist/testdata/base/logger/tarmac.wasm", }, }) @@ -119,7 +119,7 @@ func TestWASMExecution(t *testing.T) { err = s.LoadModule(ModuleConfig{ Name: "AModule", - Filepath: "/testdata/logger/tarmac.wasm", + Filepath: "/testdata/base/logger/tarmac.wasm", }) if err != nil { t.Fatalf("Failed to load module - %s", err) diff --git a/testdata/default/Makefile b/testdata/base/default/Makefile similarity index 100% rename from testdata/default/Makefile rename to testdata/base/default/Makefile diff --git a/testdata/default/docker-compose.yml b/testdata/base/default/docker-compose.yml similarity index 100% rename from testdata/default/docker-compose.yml rename to testdata/base/default/docker-compose.yml diff --git a/testdata/default/go.mod b/testdata/base/default/go.mod similarity index 100% rename from testdata/default/go.mod rename to testdata/base/default/go.mod diff --git a/testdata/default/go.sum b/testdata/base/default/go.sum similarity index 100% rename from testdata/default/go.sum rename to testdata/base/default/go.sum diff --git a/testdata/default/main.go b/testdata/base/default/main.go similarity index 100% rename from testdata/default/main.go rename to testdata/base/default/main.go diff --git a/testdata/fail/Makefile b/testdata/base/fail/Makefile similarity index 100% rename from testdata/fail/Makefile rename to testdata/base/fail/Makefile diff --git a/testdata/fail/docker-compose.yml b/testdata/base/fail/docker-compose.yml similarity index 100% rename from testdata/fail/docker-compose.yml rename to testdata/base/fail/docker-compose.yml diff --git a/testdata/fail/go.mod b/testdata/base/fail/go.mod similarity index 100% rename from testdata/fail/go.mod rename to testdata/base/fail/go.mod diff --git a/testdata/fail/go.sum b/testdata/base/fail/go.sum similarity index 100% rename from testdata/fail/go.sum rename to testdata/base/fail/go.sum diff --git a/testdata/fail/main.go b/testdata/base/fail/main.go similarity index 100% rename from testdata/fail/main.go rename to testdata/base/fail/main.go diff --git a/testdata/function/Makefile b/testdata/base/function/Makefile similarity index 100% rename from testdata/function/Makefile rename to testdata/base/function/Makefile diff --git a/testdata/function/docker-compose.yml b/testdata/base/function/docker-compose.yml similarity index 100% rename from testdata/function/docker-compose.yml rename to testdata/base/function/docker-compose.yml diff --git a/testdata/function/go.mod b/testdata/base/function/go.mod similarity index 100% rename from testdata/function/go.mod rename to testdata/base/function/go.mod diff --git a/testdata/function/go.sum b/testdata/base/function/go.sum similarity index 100% rename from testdata/function/go.sum rename to testdata/base/function/go.sum diff --git a/testdata/function/main.go b/testdata/base/function/main.go similarity index 100% rename from testdata/function/main.go rename to testdata/base/function/main.go diff --git a/testdata/kv/Makefile b/testdata/base/kv/Makefile similarity index 100% rename from testdata/kv/Makefile rename to testdata/base/kv/Makefile diff --git a/testdata/kv/docker-compose.yml b/testdata/base/kv/docker-compose.yml similarity index 100% rename from testdata/kv/docker-compose.yml rename to testdata/base/kv/docker-compose.yml diff --git a/testdata/kv/go.mod b/testdata/base/kv/go.mod similarity index 100% rename from testdata/kv/go.mod rename to testdata/base/kv/go.mod diff --git a/testdata/kv/go.sum b/testdata/base/kv/go.sum similarity index 100% rename from testdata/kv/go.sum rename to testdata/base/kv/go.sum diff --git a/testdata/kv/main.go b/testdata/base/kv/main.go similarity index 100% rename from testdata/kv/main.go rename to testdata/base/kv/main.go diff --git a/testdata/logger/Makefile b/testdata/base/logger/Makefile similarity index 100% rename from testdata/logger/Makefile rename to testdata/base/logger/Makefile diff --git a/testdata/logger/docker-compose.yml b/testdata/base/logger/docker-compose.yml similarity index 100% rename from testdata/logger/docker-compose.yml rename to testdata/base/logger/docker-compose.yml diff --git a/testdata/logger/go.mod b/testdata/base/logger/go.mod similarity index 100% rename from testdata/logger/go.mod rename to testdata/base/logger/go.mod diff --git a/testdata/logger/go.sum b/testdata/base/logger/go.sum similarity index 100% rename from testdata/logger/go.sum rename to testdata/base/logger/go.sum diff --git a/testdata/logger/main.go b/testdata/base/logger/main.go similarity index 100% rename from testdata/logger/main.go rename to testdata/base/logger/main.go diff --git a/testdata/sql/Makefile b/testdata/base/sql/Makefile similarity index 100% rename from testdata/sql/Makefile rename to testdata/base/sql/Makefile diff --git a/testdata/sql/docker-compose.yml b/testdata/base/sql/docker-compose.yml similarity index 100% rename from testdata/sql/docker-compose.yml rename to testdata/base/sql/docker-compose.yml diff --git a/testdata/sql/go.mod b/testdata/base/sql/go.mod similarity index 100% rename from testdata/sql/go.mod rename to testdata/base/sql/go.mod diff --git a/testdata/sql/go.sum b/testdata/base/sql/go.sum similarity index 100% rename from testdata/sql/go.sum rename to testdata/base/sql/go.sum diff --git a/testdata/sql/main.go b/testdata/base/sql/main.go similarity index 100% rename from testdata/sql/main.go rename to testdata/base/sql/main.go diff --git a/testdata/successafter5/Makefile b/testdata/base/successafter5/Makefile similarity index 100% rename from testdata/successafter5/Makefile rename to testdata/base/successafter5/Makefile diff --git a/testdata/successafter5/docker-compose.yml b/testdata/base/successafter5/docker-compose.yml similarity index 100% rename from testdata/successafter5/docker-compose.yml rename to testdata/base/successafter5/docker-compose.yml diff --git a/testdata/successafter5/go.mod b/testdata/base/successafter5/go.mod similarity index 100% rename from testdata/successafter5/go.mod rename to testdata/base/successafter5/go.mod diff --git a/testdata/successafter5/go.sum b/testdata/base/successafter5/go.sum similarity index 100% rename from testdata/successafter5/go.sum rename to testdata/base/successafter5/go.sum diff --git a/testdata/successafter5/main.go b/testdata/base/successafter5/main.go similarity index 100% rename from testdata/successafter5/main.go rename to testdata/base/successafter5/main.go diff --git a/testdata/sdkv1/kv/Makefile b/testdata/sdkv1/kv/Makefile new file mode 100644 index 00000000..5137f2ae --- /dev/null +++ b/testdata/sdkv1/kv/Makefile @@ -0,0 +1,10 @@ +## Makefile for Go example for Tarmac WASM functions + +build: + ## Run TinyGo build via Docker because its easier + docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + +docker-compose: + docker compose up + +run: build docker-compose diff --git a/testdata/sdkv1/kv/docker-compose.yml b/testdata/sdkv1/kv/docker-compose.yml new file mode 100644 index 00000000..848ca153 --- /dev/null +++ b/testdata/sdkv1/kv/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.8' +services: + tarmac-example: + image: madflojo/tarmac + ports: + - 80:8080 + environment: + - "APP_ENABLE_TLS=false" + - "APP_LISTEN_ADDR=0.0.0.0:8080" + - "APP_DEBUG=true" + volumes: + - "./:/functions" diff --git a/testdata/sdkv1/kv/go.mod b/testdata/sdkv1/kv/go.mod new file mode 100644 index 00000000..dc379f41 --- /dev/null +++ b/testdata/sdkv1/kv/go.mod @@ -0,0 +1,10 @@ +module github.com/tarmac-project/tarmac/testdata/kv + +go 1.21 + +require github.com/tarmac-project/tarmac/pkg/sdk v0.5.0 + +require ( + github.com/valyala/fastjson v1.6.4 // indirect + github.com/wapc/wapc-guest-tinygo v0.3.3 // indirect +) diff --git a/testdata/sdkv1/kv/go.sum b/testdata/sdkv1/kv/go.sum new file mode 100644 index 00000000..7a604dae --- /dev/null +++ b/testdata/sdkv1/kv/go.sum @@ -0,0 +1,8 @@ +github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 h1:xoIK0ctDddBMnc74udxJYBqlo9Ylnsp1waqjLsnef20= +github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M= +github.com/tarmac-project/tarmac/pkg/sdk v0.5.0 h1:QKsEf6SXTYrJM9/B4cNoM4RS3/rzuViJaiutEcdSRZQ= +github.com/tarmac-project/tarmac/pkg/sdk v0.5.0/go.mod h1:UTKYV0QFdkJDgV2sJcnuCujVy49MCd8bgi2JmwviJ6E= +github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= +github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= +github.com/wapc/wapc-guest-tinygo v0.3.3 h1:jLebiwjVSHLGnS+BRabQ6+XOV7oihVWAc05Hf1SbeR0= +github.com/wapc/wapc-guest-tinygo v0.3.3/go.mod h1:mzM3CnsdSYktfPkaBdZ8v88ZlfUDEy5Jh5XBOV3fYcw= diff --git a/testdata/sdkv1/kv/main.go b/testdata/sdkv1/kv/main.go new file mode 100644 index 00000000..2fea62a8 --- /dev/null +++ b/testdata/sdkv1/kv/main.go @@ -0,0 +1,43 @@ +// This program is a test program used to facilitate unit testing with Tarmac. +package main + +import ( + "fmt" + + "github.com/tarmac-project/tarmac/pkg/sdk" +) + +var tarmac *sdk.Tarmac + +func main() { + var err error + + // Initialize the Tarmac SDK + tarmac, err = sdk.New(sdk.Config{Namespace: "tarmac", Handler: Handler}) + if err != nil { + return + } +} + +func Handler(payload []byte) ([]byte, error) { + // Store data within KV datastore + err := tarmac.KV.Set("test-data", []byte("i am a little teapot")) + if err != nil { + return []byte(""), fmt.Errorf(`Failed to store data via KVStore - %s`, err) + } + + // Fetch data from KV datastore + data, err := tarmac.KV.Get("test-data") + if err != nil { + return []byte(""), fmt.Errorf(`Failed to fetch data via KVStore - %s`, err) + } + + tarmac.Logger.Info(fmt.Sprintf("Fetched %s from datastore", data)) + + if len(data) != len([]byte("i am a little teapot")) { + return []byte(""), fmt.Errorf("not able to fetch data from KVStore") + } + + // Return a happy message + return []byte("Howdie"), nil +} diff --git a/testdata/sdkv1/logger/Makefile b/testdata/sdkv1/logger/Makefile new file mode 100644 index 00000000..5137f2ae --- /dev/null +++ b/testdata/sdkv1/logger/Makefile @@ -0,0 +1,10 @@ +## Makefile for Go example for Tarmac WASM functions + +build: + ## Run TinyGo build via Docker because its easier + docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + +docker-compose: + docker compose up + +run: build docker-compose diff --git a/testdata/sdkv1/logger/docker-compose.yml b/testdata/sdkv1/logger/docker-compose.yml new file mode 100644 index 00000000..848ca153 --- /dev/null +++ b/testdata/sdkv1/logger/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.8' +services: + tarmac-example: + image: madflojo/tarmac + ports: + - 80:8080 + environment: + - "APP_ENABLE_TLS=false" + - "APP_LISTEN_ADDR=0.0.0.0:8080" + - "APP_DEBUG=true" + volumes: + - "./:/functions" diff --git a/testdata/sdkv1/logger/go.mod b/testdata/sdkv1/logger/go.mod new file mode 100644 index 00000000..28d889e9 --- /dev/null +++ b/testdata/sdkv1/logger/go.mod @@ -0,0 +1,10 @@ +module github.com/tarmac-project/tarmac/testdata/logger + +go 1.20 + +require github.com/tarmac-project/tarmac/pkg/sdk v0.5.0 + +require ( + github.com/valyala/fastjson v1.6.4 // indirect + github.com/wapc/wapc-guest-tinygo v0.3.3 // indirect +) diff --git a/testdata/sdkv1/logger/go.sum b/testdata/sdkv1/logger/go.sum new file mode 100644 index 00000000..0b9211cc --- /dev/null +++ b/testdata/sdkv1/logger/go.sum @@ -0,0 +1,7 @@ +github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 h1:xoIK0ctDddBMnc74udxJYBqlo9Ylnsp1waqjLsnef20= +github.com/tarmac-project/tarmac/pkg/sdk v0.5.0 h1:QKsEf6SXTYrJM9/B4cNoM4RS3/rzuViJaiutEcdSRZQ= +github.com/tarmac-project/tarmac/pkg/sdk v0.5.0/go.mod h1:UTKYV0QFdkJDgV2sJcnuCujVy49MCd8bgi2JmwviJ6E= +github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= +github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= +github.com/wapc/wapc-guest-tinygo v0.3.3 h1:jLebiwjVSHLGnS+BRabQ6+XOV7oihVWAc05Hf1SbeR0= +github.com/wapc/wapc-guest-tinygo v0.3.3/go.mod h1:mzM3CnsdSYktfPkaBdZ8v88ZlfUDEy5Jh5XBOV3fYcw= diff --git a/testdata/sdkv1/logger/main.go b/testdata/sdkv1/logger/main.go new file mode 100644 index 00000000..d71dcc91 --- /dev/null +++ b/testdata/sdkv1/logger/main.go @@ -0,0 +1,28 @@ +// This program is a test program used to facilitate unit testing with Tarmac. +package main + +import ( + "fmt" + + "github.com/tarmac-project/tarmac/pkg/sdk" +) + +var tarmac *sdk.Tarmac + +func main() { + var err error + + // Initialize the Tarmac SDK + tarmac, err = sdk.New(sdk.Config{Namespace: "tarmac", Handler: Handler}) + if err != nil { + return + } +} + +func Handler(payload []byte) ([]byte, error) { + // Log the payload + tarmac.Logger.Info(fmt.Sprintf("Testdata function - %s", payload)) + + // Return a happy message + return payload, nil +} diff --git a/testdata/sdkv1/sql/Makefile b/testdata/sdkv1/sql/Makefile new file mode 100644 index 00000000..5137f2ae --- /dev/null +++ b/testdata/sdkv1/sql/Makefile @@ -0,0 +1,10 @@ +## Makefile for Go example for Tarmac WASM functions + +build: + ## Run TinyGo build via Docker because its easier + docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + +docker-compose: + docker compose up + +run: build docker-compose diff --git a/testdata/sdkv1/sql/docker-compose.yml b/testdata/sdkv1/sql/docker-compose.yml new file mode 100644 index 00000000..848ca153 --- /dev/null +++ b/testdata/sdkv1/sql/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.8' +services: + tarmac-example: + image: madflojo/tarmac + ports: + - 80:8080 + environment: + - "APP_ENABLE_TLS=false" + - "APP_LISTEN_ADDR=0.0.0.0:8080" + - "APP_DEBUG=true" + volumes: + - "./:/functions" diff --git a/testdata/sdkv1/sql/go.mod b/testdata/sdkv1/sql/go.mod new file mode 100644 index 00000000..2bcde009 --- /dev/null +++ b/testdata/sdkv1/sql/go.mod @@ -0,0 +1,10 @@ +module github.com/tarmac-project/tarmac/testdata/sql + +go 1.20 + +require github.com/tarmac-project/tarmac/pkg/sdk v0.5.0 + +require ( + github.com/valyala/fastjson v1.6.4 // indirect + github.com/wapc/wapc-guest-tinygo v0.3.3 // indirect +) diff --git a/testdata/sdkv1/sql/go.sum b/testdata/sdkv1/sql/go.sum new file mode 100644 index 00000000..0b9211cc --- /dev/null +++ b/testdata/sdkv1/sql/go.sum @@ -0,0 +1,7 @@ +github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 h1:xoIK0ctDddBMnc74udxJYBqlo9Ylnsp1waqjLsnef20= +github.com/tarmac-project/tarmac/pkg/sdk v0.5.0 h1:QKsEf6SXTYrJM9/B4cNoM4RS3/rzuViJaiutEcdSRZQ= +github.com/tarmac-project/tarmac/pkg/sdk v0.5.0/go.mod h1:UTKYV0QFdkJDgV2sJcnuCujVy49MCd8bgi2JmwviJ6E= +github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= +github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= +github.com/wapc/wapc-guest-tinygo v0.3.3 h1:jLebiwjVSHLGnS+BRabQ6+XOV7oihVWAc05Hf1SbeR0= +github.com/wapc/wapc-guest-tinygo v0.3.3/go.mod h1:mzM3CnsdSYktfPkaBdZ8v88ZlfUDEy5Jh5XBOV3fYcw= diff --git a/testdata/sdkv1/sql/main.go b/testdata/sdkv1/sql/main.go new file mode 100644 index 00000000..3ab85a1b --- /dev/null +++ b/testdata/sdkv1/sql/main.go @@ -0,0 +1,32 @@ +// This program is a test program used to facilitate unit testing with Tarmac. +package main + +import ( + "fmt" + + "github.com/tarmac-project/tarmac/pkg/sdk" +) + +var tarmac *sdk.Tarmac + +func main() { + var err error + + // Initialize the Tarmac SDK + tarmac, err = sdk.New(sdk.Config{Namespace: "tarmac", Handler: Handler}) + if err != nil { + return + } +} + +func Handler(payload []byte) ([]byte, error) { + // SQL Query + _, err := tarmac.SQL.Query(`CREATE TABLE IF NOT EXISTS wasmguest ( id int NOT NULL, name varchar(255), PRIMARY KEY (id) );`) + if err != nil { + tarmac.Logger.Error(fmt.Sprintf("Unable to execute SQL query - %s", err)) + return []byte(""), fmt.Errorf(`Failed to SQL callback - %s`, err) + } + + // Return a happy message + return []byte("Howdie"), nil +} diff --git a/testdata/sdkv1/tarmac.json b/testdata/sdkv1/tarmac.json new file mode 100644 index 00000000..16a0f914 --- /dev/null +++ b/testdata/sdkv1/tarmac.json @@ -0,0 +1,72 @@ +{ + "services": { + "test-service": { + "name": "test-service", + "functions": { + "default": { + "filepath": "/testdata/base/default/tarmac.wasm" + }, + "kv": { + "filepath": "/testdata/sdkv1/kv/tarmac.wasm", + "pool_size": 1000 + }, + "logger": { + "filepath": "/testdata/sdkv1/logger/tarmac.wasm" + }, + "sql": { + "filepath": "/testdata/sdkv1/sql/tarmac.wasm", + "pool_size": 10 + }, + "func": { + "filepath": "/testdata/base/function/tarmac.wasm", + "pool_size": 1 + } + }, + "routes": [ + { + "type": "init", + "function": "default" + }, + { + "type": "http", + "path": "/", + "methods": ["GET", "POST", "PUT"], + "function": "default" + }, + { + "type": "http", + "path": "/kv", + "methods": ["GET"], + "function": "kv" + }, + { + "type": "http", + "path": "/logger", + "methods": ["GET", "POST"], + "function": "logger" + }, + { + "type": "http", + "path": "/sql", + "methods": ["GET"], + "function": "sql" + }, + { + "type": "http", + "path": "/func", + "methods": ["GET"], + "function": "func" + }, + { + "type": "scheduled_task", + "frequency": 15, + "function": "default" + }, + { + "type": "function", + "function": "logger" + } + ] + } + } +} diff --git a/testdata/tarmac-fail.json b/testdata/tarmac-fail.json index d69f8576..8f74f72b 100644 --- a/testdata/tarmac-fail.json +++ b/testdata/tarmac-fail.json @@ -4,7 +4,7 @@ "name": "test-service", "functions": { "fail": { - "filepath": "/testdata/fail/tarmac.wasm" + "filepath": "/testdata/base/fail/tarmac.wasm" } }, "routes": [ diff --git a/testdata/tarmac.json b/testdata/tarmac.json index 6a223fce..e59a1015 100644 --- a/testdata/tarmac.json +++ b/testdata/tarmac.json @@ -4,21 +4,21 @@ "name": "test-service", "functions": { "default": { - "filepath": "/testdata/default/tarmac.wasm" + "filepath": "/testdata/base/default/tarmac.wasm" }, "kv": { - "filepath": "/testdata/kv/tarmac.wasm", + "filepath": "/testdata/base/kv/tarmac.wasm", "pool_size": 1000 }, "logger": { - "filepath": "/testdata/logger/tarmac.wasm" + "filepath": "/testdata/base/logger/tarmac.wasm" }, "sql": { - "filepath": "/testdata/sql/tarmac.wasm", + "filepath": "/testdata/base/sql/tarmac.wasm", "pool_size": 10 }, "func": { - "filepath": "/testdata/function/tarmac.wasm", + "filepath": "/testdata/base/function/tarmac.wasm", "pool_size": 1 } }, From e5df20cacf5425d0006b580e10f2d02c7447a666 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 13 Oct 2024 08:12:23 -0700 Subject: [PATCH 21/31] Update pkg/callbacks/sql/sql_test.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- pkg/callbacks/sql/sql_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/callbacks/sql/sql_test.go b/pkg/callbacks/sql/sql_test.go index df797dff..a717c08a 100644 --- a/pkg/callbacks/sql/sql_test.go +++ b/pkg/callbacks/sql/sql_test.go @@ -78,7 +78,7 @@ func TestSQLQuery(t *testing.T) { r, err := db.Query(qMsg) if err == nil { - t.Fatalf("Unexepected success with failure test case") + t.Fatalf("Unexpected success with failure test case") } // Unmarshal the Tarmac Response From 36bd71b80eefa802b4667a10b7943fab6fa7d812 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 13 Oct 2024 08:26:05 -0700 Subject: [PATCH 22/31] feat(sql): upgrade dependencies and enhance logging Upgraded TinyGo version and enhanced SQL handling to improve stability. Logging now adds a touch of empathy, so errors feel warm and cozy. --- testdata/base/sql/Makefile | 2 +- testdata/base/sql/go.mod | 11 ++++++++--- testdata/base/sql/go.sum | 11 +++++++++++ testdata/base/sql/main.go | 34 ++++++++++++++++++++++++++++++---- 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/testdata/base/sql/Makefile b/testdata/base/sql/Makefile index 5137f2ae..fb6782e2 100644 --- a/testdata/base/sql/Makefile +++ b/testdata/base/sql/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.32.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up diff --git a/testdata/base/sql/go.mod b/testdata/base/sql/go.mod index 2bcde009..b95a80c3 100644 --- a/testdata/base/sql/go.mod +++ b/testdata/base/sql/go.mod @@ -1,10 +1,15 @@ module github.com/tarmac-project/tarmac/testdata/sql -go 1.20 +go 1.22.6 -require github.com/tarmac-project/tarmac/pkg/sdk v0.5.0 +require ( + github.com/tarmac-project/protobuf-go v0.0.0-20241006222641-e31a4349f2b8 + github.com/tarmac-project/tarmac/pkg/sdk v0.5.0 + github.com/wapc/wapc-guest-tinygo v0.3.3 + google.golang.org/protobuf v1.35.1 +) require ( + github.com/planetscale/vtprotobuf v0.6.0 // indirect github.com/valyala/fastjson v1.6.4 // indirect - github.com/wapc/wapc-guest-tinygo v0.3.3 // indirect ) diff --git a/testdata/base/sql/go.sum b/testdata/base/sql/go.sum index 0b9211cc..e6183712 100644 --- a/testdata/base/sql/go.sum +++ b/testdata/base/sql/go.sum @@ -1,7 +1,18 @@ +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/planetscale/vtprotobuf v0.6.0 h1:nBeETjudeJ5ZgBHUz1fVHvbqUKnYOXNhsIEabROxmNA= +github.com/planetscale/vtprotobuf v0.6.0/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 h1:xoIK0ctDddBMnc74udxJYBqlo9Ylnsp1waqjLsnef20= +github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M= +github.com/tarmac-project/protobuf-go v0.0.0-20241006222641-e31a4349f2b8 h1:RgbhOg4t09fylA1limKplGMXi3HS8altC6Q4lHIkVaI= +github.com/tarmac-project/protobuf-go v0.0.0-20241006222641-e31a4349f2b8/go.mod h1:TtJAJlZ8d1xmkN32J8HHtvWOBPZMxEOg//yJeBXfbmw= github.com/tarmac-project/tarmac/pkg/sdk v0.5.0 h1:QKsEf6SXTYrJM9/B4cNoM4RS3/rzuViJaiutEcdSRZQ= github.com/tarmac-project/tarmac/pkg/sdk v0.5.0/go.mod h1:UTKYV0QFdkJDgV2sJcnuCujVy49MCd8bgi2JmwviJ6E= github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= github.com/wapc/wapc-guest-tinygo v0.3.3 h1:jLebiwjVSHLGnS+BRabQ6+XOV7oihVWAc05Hf1SbeR0= github.com/wapc/wapc-guest-tinygo v0.3.3/go.mod h1:mzM3CnsdSYktfPkaBdZ8v88ZlfUDEy5Jh5XBOV3fYcw= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= diff --git a/testdata/base/sql/main.go b/testdata/base/sql/main.go index 3ab85a1b..c5529741 100644 --- a/testdata/base/sql/main.go +++ b/testdata/base/sql/main.go @@ -5,6 +5,10 @@ import ( "fmt" "github.com/tarmac-project/tarmac/pkg/sdk" + wapc "github.com/wapc/wapc-guest-tinygo" + + "github.com/tarmac-project/protobuf-go/sdk/sql" + pb "google.golang.org/protobuf/proto" ) var tarmac *sdk.Tarmac @@ -20,11 +24,33 @@ func main() { } func Handler(payload []byte) ([]byte, error) { - // SQL Query - _, err := tarmac.SQL.Query(`CREATE TABLE IF NOT EXISTS wasmguest ( id int NOT NULL, name varchar(255), PRIMARY KEY (id) );`) + // Create SQL Request + query := &sql.SQLQuery{Query: []byte(`CREATE TABLE IF NOT EXISTS wasmguest ( id int NOT NULL, name varchar(255), PRIMARY KEY (id) );`)} + q, err := pb.Marshal(query) if err != nil { - tarmac.Logger.Error(fmt.Sprintf("Unable to execute SQL query - %s", err)) - return []byte(""), fmt.Errorf(`Failed to SQL callback - %s`, err) + tarmac.Logger.Error(fmt.Sprintf("Unable to marshal SQL query - %s", err)) + return []byte(""), fmt.Errorf(`Failed to marshal SQL query - %s`, err) + } + + // Call the SQL capability + rsp, err := wapc.HostCall("tarmac", "sql", "query", q) + if err != nil { + tarmac.Logger.Error(fmt.Sprintf("Unable to call SQL capability - %s", err)) + return []byte(""), fmt.Errorf(`Failed to call SQL capability - %s`, err) + } + + // Unmarshal the response + var response sql.SQLQueryResponse + err = pb.Unmarshal(rsp, &response) + if err != nil { + tarmac.Logger.Error(fmt.Sprintf("Unable to unmarshal SQL response - %s", err)) + return []byte(""), fmt.Errorf(`Failed to unmarshal SQL response - %s`, err) + } + + // Validate the response + if response.Status.Code != 200 { + tarmac.Logger.Error(fmt.Sprintf("SQL query failed - %s", response.Status.Status)) + return []byte(""), fmt.Errorf(`SQL query failed - %s`, response.Status.Status) } // Return a happy message From 65c84265e9f067f93bd01e4381168cc9b8f0acb4 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 13 Oct 2024 08:36:31 -0700 Subject: [PATCH 23/31] fix(makefile): update volume path for clarity Refactored Docker volume path in the Makefile to distinguish it from the rest. Because even build directories deserve a touch of individuality! --- testdata/base/sql/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/base/sql/Makefile b/testdata/base/sql/Makefile index fb6782e2..3f0de467 100644 --- a/testdata/base/sql/Makefile +++ b/testdata/base/sql/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.32.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`/:/tarmacbuild -w /tarmacbuild tinygo/tinygo:0.32.0 tinygo build -o /tarmacbuild/tarmac.wasm -target wasi /tarmacbuild/main.go docker-compose: docker compose up From 31e86ea096f0644694fee3218b247ab78d303a9b Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 13 Oct 2024 08:44:08 -0700 Subject: [PATCH 24/31] fix(makefile): adjust volume mount path for sanity Tweaked the volume mount path because even directories get lost sometimes. Don't worry, they're safe at "/build" now! --- testdata/base/sql/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/base/sql/Makefile b/testdata/base/sql/Makefile index 3f0de467..2bf02dce 100644 --- a/testdata/base/sql/Makefile +++ b/testdata/base/sql/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run --rm -v `pwd`/:/tarmacbuild -w /tarmacbuild tinygo/tinygo:0.32.0 tinygo build -o /tarmacbuild/tarmac.wasm -target wasi /tarmacbuild/main.go + docker run --rm -v `pwd`/:/build -u root -w /build tinygo/tinygo:0.32.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up From c76f747a88f80e4ad1280261e829709f893bb59d Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 13 Oct 2024 09:04:33 -0700 Subject: [PATCH 25/31] refactor(sql): optimize protobuf marshalling methods Replaced `proto` methods with `VT` for better performance. Now, it's faster than your morning coffee! --- testdata/base/sql/go.mod | 2 +- testdata/base/sql/main.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/testdata/base/sql/go.mod b/testdata/base/sql/go.mod index b95a80c3..abd9b9a8 100644 --- a/testdata/base/sql/go.mod +++ b/testdata/base/sql/go.mod @@ -6,10 +6,10 @@ require ( github.com/tarmac-project/protobuf-go v0.0.0-20241006222641-e31a4349f2b8 github.com/tarmac-project/tarmac/pkg/sdk v0.5.0 github.com/wapc/wapc-guest-tinygo v0.3.3 - google.golang.org/protobuf v1.35.1 ) require ( github.com/planetscale/vtprotobuf v0.6.0 // indirect github.com/valyala/fastjson v1.6.4 // indirect + google.golang.org/protobuf v1.35.1 // indirect ) diff --git a/testdata/base/sql/main.go b/testdata/base/sql/main.go index c5529741..038d475d 100644 --- a/testdata/base/sql/main.go +++ b/testdata/base/sql/main.go @@ -8,7 +8,6 @@ import ( wapc "github.com/wapc/wapc-guest-tinygo" "github.com/tarmac-project/protobuf-go/sdk/sql" - pb "google.golang.org/protobuf/proto" ) var tarmac *sdk.Tarmac @@ -26,7 +25,7 @@ func main() { func Handler(payload []byte) ([]byte, error) { // Create SQL Request query := &sql.SQLQuery{Query: []byte(`CREATE TABLE IF NOT EXISTS wasmguest ( id int NOT NULL, name varchar(255), PRIMARY KEY (id) );`)} - q, err := pb.Marshal(query) + q, err := query.MarshalVT() if err != nil { tarmac.Logger.Error(fmt.Sprintf("Unable to marshal SQL query - %s", err)) return []byte(""), fmt.Errorf(`Failed to marshal SQL query - %s`, err) @@ -41,7 +40,7 @@ func Handler(payload []byte) ([]byte, error) { // Unmarshal the response var response sql.SQLQueryResponse - err = pb.Unmarshal(rsp, &response) + err = response.UnmarshalVT(rsp) if err != nil { tarmac.Logger.Error(fmt.Sprintf("Unable to unmarshal SQL response - %s", err)) return []byte(""), fmt.Errorf(`Failed to unmarshal SQL response - %s`, err) From 99f6b2c479a59eee405cb247f40ec2471fe2f7ea Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 13 Oct 2024 09:28:34 -0700 Subject: [PATCH 26/31] chore(makefile): update TinyGo version to latest Updated Makefiles to use the latest TinyGo release. I guess we all want to live on the edge now and then. --- testdata/base/default/Makefile | 2 +- testdata/base/fail/Makefile | 2 +- testdata/base/function/Makefile | 2 +- testdata/base/kv/Makefile | 2 +- testdata/base/logger/Makefile | 2 +- testdata/base/sql/Makefile | 2 +- testdata/base/successafter5/Makefile | 2 +- testdata/sdkv1/kv/Makefile | 2 +- testdata/sdkv1/logger/Makefile | 2 +- testdata/sdkv1/sql/Makefile | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/testdata/base/default/Makefile b/testdata/base/default/Makefile index 463b506a..c98f63b8 100644 --- a/testdata/base/default/Makefile +++ b/testdata/base/default/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run --rm -v `pwd`:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`:/build -w /build -u root tinygo/tinygo:latest tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up diff --git a/testdata/base/fail/Makefile b/testdata/base/fail/Makefile index 463b506a..c98f63b8 100644 --- a/testdata/base/fail/Makefile +++ b/testdata/base/fail/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run --rm -v `pwd`:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`:/build -w /build -u root tinygo/tinygo:latest tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up diff --git a/testdata/base/function/Makefile b/testdata/base/function/Makefile index 5137f2ae..a6918cec 100644 --- a/testdata/base/function/Makefile +++ b/testdata/base/function/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`/:/build -w /build -u root tinygo/tinygo:latest tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up diff --git a/testdata/base/kv/Makefile b/testdata/base/kv/Makefile index 5137f2ae..a6918cec 100644 --- a/testdata/base/kv/Makefile +++ b/testdata/base/kv/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`/:/build -w /build -u root tinygo/tinygo:latest tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up diff --git a/testdata/base/logger/Makefile b/testdata/base/logger/Makefile index 5137f2ae..a6918cec 100644 --- a/testdata/base/logger/Makefile +++ b/testdata/base/logger/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`/:/build -w /build -u root tinygo/tinygo:latest tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up diff --git a/testdata/base/sql/Makefile b/testdata/base/sql/Makefile index 2bf02dce..a6918cec 100644 --- a/testdata/base/sql/Makefile +++ b/testdata/base/sql/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run --rm -v `pwd`/:/build -u root -w /build tinygo/tinygo:0.32.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`/:/build -w /build -u root tinygo/tinygo:latest tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up diff --git a/testdata/base/successafter5/Makefile b/testdata/base/successafter5/Makefile index 463b506a..c98f63b8 100644 --- a/testdata/base/successafter5/Makefile +++ b/testdata/base/successafter5/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run --rm -v `pwd`:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`:/build -w /build -u root tinygo/tinygo:latest tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up diff --git a/testdata/sdkv1/kv/Makefile b/testdata/sdkv1/kv/Makefile index 5137f2ae..a6918cec 100644 --- a/testdata/sdkv1/kv/Makefile +++ b/testdata/sdkv1/kv/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`/:/build -w /build -u root tinygo/tinygo:latest tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up diff --git a/testdata/sdkv1/logger/Makefile b/testdata/sdkv1/logger/Makefile index 5137f2ae..a6918cec 100644 --- a/testdata/sdkv1/logger/Makefile +++ b/testdata/sdkv1/logger/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`/:/build -w /build -u root tinygo/tinygo:latest tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up diff --git a/testdata/sdkv1/sql/Makefile b/testdata/sdkv1/sql/Makefile index 5137f2ae..a6918cec 100644 --- a/testdata/sdkv1/sql/Makefile +++ b/testdata/sdkv1/sql/Makefile @@ -2,7 +2,7 @@ build: ## Run TinyGo build via Docker because its easier - docker run --rm -v `pwd`/:/build -w /build tinygo/tinygo:0.25.0 tinygo build -o /build/tarmac.wasm -target wasi /build/main.go + docker run --rm -v `pwd`/:/build -w /build -u root tinygo/tinygo:latest tinygo build -o /build/tarmac.wasm -target wasi /build/main.go docker-compose: docker compose up From 98dcc4d89a9afc881d3dfb1654e9075d482362cb Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 13 Oct 2024 09:49:01 -0700 Subject: [PATCH 27/31] Update pkg/callbacks/sql/sql_test.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- pkg/callbacks/sql/sql_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/callbacks/sql/sql_test.go b/pkg/callbacks/sql/sql_test.go index a717c08a..d02ed23c 100644 --- a/pkg/callbacks/sql/sql_test.go +++ b/pkg/callbacks/sql/sql_test.go @@ -187,7 +187,7 @@ func TestSQLQuery(t *testing.T) { } // Check Column Names - if rsp.Columns[0] != "id" && rsp.Columns[1] != "name" { + if rsp.Columns[0] != "id" || rsp.Columns[1] != "name" { t.Fatalf("Unexpected column names returned - %v", rsp.Columns) } From 688be1b4f9a0af338fe3cdafd8c6e57cf91e5283 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 13 Oct 2024 09:49:30 -0700 Subject: [PATCH 28/31] chore: switch to errors package and fix JSON keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced fmt.Errorf with errors package—because sometimes even errors need a makeover. Also, JSON keys get a lower-case makeover for their "value" personality. --- pkg/callbacks/kvstore/kvstore.go | 3 ++- pkg/callbacks/metrics/metrics_test.go | 4 ++-- pkg/callbacks/sql/sql.go | 3 ++- pkg/callbacks/sql/sql_test.go | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/callbacks/kvstore/kvstore.go b/pkg/callbacks/kvstore/kvstore.go index ca961bcd..d80e19e7 100644 --- a/pkg/callbacks/kvstore/kvstore.go +++ b/pkg/callbacks/kvstore/kvstore.go @@ -21,6 +21,7 @@ package kvstore import ( "encoding/base64" + "errors" "fmt" "github.com/pquerna/ffjson/ffjson" @@ -53,7 +54,7 @@ type Config struct { var ( // ErrNilKey is returned when the key is nil - ErrNilKey = fmt.Errorf("key cannot be nil") + ErrNilKey = errors.New("key cannot be nil") ) // New will create and return a new KVStore instance that users can register as a Tarmac Host Callback function. Users diff --git a/pkg/callbacks/metrics/metrics_test.go b/pkg/callbacks/metrics/metrics_test.go index 467e00e7..01b7e0e2 100644 --- a/pkg/callbacks/metrics/metrics_test.go +++ b/pkg/callbacks/metrics/metrics_test.go @@ -408,7 +408,7 @@ func TestMetricsCallbackJSON(t *testing.T) { Callback: "histogram", Exists: false, Key: "json_happy_path", - JSON: `{"name":"json_happy_path","Value":0.11231}`, + JSON: `{"name":"json_happy_path","value":0.11231}`, }) tc = append(tc, MetricsCaseJSON{ @@ -417,7 +417,7 @@ func TestMetricsCallbackJSON(t *testing.T) { Callback: "histogram", Exists: true, Key: "json_happy_path_histo", - JSON: `{"name":"json_happy_path_histo","Value":0.11231}`, + JSON: `{"name":"json_happy_path_histo","value":0.11231}`, }) tc = append(tc, MetricsCaseJSON{ diff --git a/pkg/callbacks/sql/sql.go b/pkg/callbacks/sql/sql.go index a14f08d6..2d8710d7 100644 --- a/pkg/callbacks/sql/sql.go +++ b/pkg/callbacks/sql/sql.go @@ -257,7 +257,8 @@ func (db *Database) query(qry []byte) ([]string, []map[string]any, error) { m := make(map[string]any) for i, c := range columns { - m[c] = data[i] + val := *data[i].(*interface{}) + m[c] = val } results = append(results, m) diff --git a/pkg/callbacks/sql/sql_test.go b/pkg/callbacks/sql/sql_test.go index d02ed23c..b67f4437 100644 --- a/pkg/callbacks/sql/sql_test.go +++ b/pkg/callbacks/sql/sql_test.go @@ -131,7 +131,7 @@ func TestSQLQuery(t *testing.T) { r, err := db.Exec(qMsg) if err != nil { - t.Errorf("Unable to execute table creation query - %s", err) + t.Errorf("Unable to execute INSERT query - %s", err) } // Unmarshal the Tarmac Response @@ -166,7 +166,7 @@ func TestSQLQuery(t *testing.T) { r, err := db.Query(qMsg) if err != nil { - t.Errorf("Unable to execute table creation query - %s", err) + t.Errorf("Unable to execute SELECT query - %s", err) } // Unmarshal the Tarmac Response @@ -207,7 +207,7 @@ func TestSQLQuery(t *testing.T) { r, err := db.Query(qMsg) if err != nil { - t.Errorf("Unable to execute table creation query - %s", err) + t.Errorf("Unable to execute DELETE TABLE query - %s", err) } // Unmarshal the Tarmac Response From f8b69d557752aa2cf2daed5b5493ff3713e8b630 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 13 Oct 2024 10:01:50 -0700 Subject: [PATCH 29/31] fix(sql): un-indent the universe Straighten out column handling because spaces are rebels without a cause. --- pkg/callbacks/sql/sql.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/callbacks/sql/sql.go b/pkg/callbacks/sql/sql.go index 2d8710d7..95ec26e1 100644 --- a/pkg/callbacks/sql/sql.go +++ b/pkg/callbacks/sql/sql.go @@ -257,7 +257,7 @@ func (db *Database) query(qry []byte) ([]string, []map[string]any, error) { m := make(map[string]any) for i, c := range columns { - val := *data[i].(*interface{}) + val := *data[i].(*interface{}) m[c] = val } From 2ac6babccd584ee6176e789a1498b0471226766f Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 13 Oct 2024 10:25:05 -0700 Subject: [PATCH 30/31] Update pkg/callbacks/sql/sql_test.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- pkg/callbacks/sql/sql_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/callbacks/sql/sql_test.go b/pkg/callbacks/sql/sql_test.go index b67f4437..f6292578 100644 --- a/pkg/callbacks/sql/sql_test.go +++ b/pkg/callbacks/sql/sql_test.go @@ -234,7 +234,7 @@ func TestSQLQuery(t *testing.T) { t.Run(c.name, func(t *testing.T) { r, err := db.Query([]byte(fmt.Sprintf(`{"query":"%s"}`, base64.StdEncoding.EncodeToString([]byte(c.q))))) if err == nil { - t.Fatalf("Unexepected success with failure test case") + t.Fatalf("Unexpected success with failure test case") } // Unmarshal the Tarmac Response From d56840254dec9e6ecd7491c80bcf562632386c09 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 13 Oct 2024 10:41:14 -0700 Subject: [PATCH 31/31] test(sql): add comprehensive SQLExec test cases Added a delightful bouquet of tests for SQLExec, including your standard 'Happy Path' stroll, an 'Unhappy Path' stumble, and the 'Empty Exec' shrug. Who knew SQL testing could be such an emotional rollercoaster? --- pkg/callbacks/sql/sql_test.go | 77 +++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/pkg/callbacks/sql/sql_test.go b/pkg/callbacks/sql/sql_test.go index f6292578..ad1f8efc 100644 --- a/pkg/callbacks/sql/sql_test.go +++ b/pkg/callbacks/sql/sql_test.go @@ -226,6 +226,83 @@ func TestSQLQuery(t *testing.T) { }) }) + t.Run("Test SQLExec", func(t *testing.T) { + t.Run("Happy Path", func(t *testing.T) { + query := &proto.SQLExec{Query: []byte(`CREATE TABLE IF NOT EXISTS testpkg ( id int NOT NULL AUTO_INCREMENT, name varchar(255), PRIMARY KEY (id) );`)} + qMsg, err := pb.Marshal(query) + if err != nil { + t.Fatalf("Unable to marshal query message") + } + + r, err := db.Exec(qMsg) + if err != nil { + t.Fatalf("Unable to execute table creation query - %s", err) + } + + // Unmarshal the Tarmac Response + var rsp proto.SQLExecResponse + err = pb.Unmarshal(r, &rsp) + if err != nil { + t.Fatalf("Error parsing returned query response") + } + + // Check Status Codes + if rsp.Status.Code != 200 { + t.Fatalf("Callback execution did not work, returned %d - %s", rsp.Status.Code, rsp.Status.Status) + } + }) + + t.Run("Unhappy Path", func(t *testing.T) { + query := &proto.SQLExec{Query: []byte(`CREATE TALBE;`)} + qMsg, err := pb.Marshal(query) + if err != nil { + t.Fatalf("Unable to marshal query message") + } + + r, err := db.Exec(qMsg) + if err == nil { + t.Fatalf("Unexpected success with failure test case") + } + + // Unmarshal the Tarmac Response + var rsp proto.SQLExecResponse + err = pb.Unmarshal(r, &rsp) + if err != nil { + t.Fatalf("Error parsing returned query response") + } + + // Check Status Codes + if rsp.Status.Code == 200 { + t.Fatalf("Unexpected Success with unhappy path test - %d", rsp.Status.Code) + } + }) + + t.Run("Empty Exec", func(t *testing.T) { + query := &proto.SQLExec{} + qMsg, err := pb.Marshal(query) + if err != nil { + t.Fatalf("Unable to marshal query message") + } + + r, err := db.Exec(qMsg) + if err == nil { + t.Fatalf("Unexpected success with failure test case") + } + + // Unmarshal the Tarmac Response + var rsp proto.SQLExecResponse + err = pb.Unmarshal(r, &rsp) + if err != nil { + t.Fatalf("Error parsing returned query response") + } + + // Check Status Codes + if rsp.Status.Code == 200 { + t.Fatalf("Unexpected Success with unhappy path test - %d", rsp.Status.Code) + } + }) + }) + // Test the JSON Interface for Backwards Compatibility t.Run("JSON Based Queries", func(t *testing.T) {