diff --git a/docs/howto/upload.md b/docs/howto/upload.md index 0add35c942..b974252afc 100644 --- a/docs/howto/upload.md +++ b/docs/howto/upload.md @@ -1,35 +1,26 @@ # Uploading projects -*This feature requires signing up for [sqlc Cloud](https://app.sqlc.dev), which is currently in beta.* +*Added in v1.22.0* -Uploading your project ensures that future releases of sqlc do not break your -existing code. Similar to Rust's [crater](https://github.com/rust-lang/crater) -project, uploaded projects are tested against development releases of sqlc to +Uploading an archive of your project ensures that future releases of sqlc do not +break your code. Similar to Rust's [crater](https://github.com/rust-lang/crater) +project, uploaded archives are tested against development releases of sqlc to verify correctness. +Interested in uploading projects? Sign up [here](https://docs.google.com/forms/d/e/1FAIpQLSdxoMzJ7rKkBpuez-KyBcPNyckYV-5iMR--FRB7WnhvAmEvKg/viewform) or send us an email +at [hello@sqlc.dev](mailto:hello@sqlc.dev). + ## Add configuration After creating a project, add the project ID to your sqlc configuration file. ```yaml -version: "1" -project: - id: "" -packages: [] -``` - -```json -{ - "version": "1", - "project": { - "id": "" - }, - "packages": [ - ] -} +version: "2" +cloud: + project: "" ``` -You'll also need to create an API token and make it available via the +You'll also need to create an auth token and make it available via the `SQLC_AUTH_TOKEN` environment variable. ```shell @@ -38,13 +29,14 @@ export SQLC_AUTH_TOKEN=sqlc_xxxxxxxx ## Dry run -You can see what's included when uploading your project by using using the `--dry-run` flag: +You can see what's included when uploading your project by using using the +`--dry-run` flag: ```shell sqlc upload --dry-run ``` -The output will be the exact HTTP request sent by `sqlc`. +The output is the request `sqlc` would have sent without the `--dry-run` flag. ## Upload @@ -54,4 +46,4 @@ Once you're ready to upload, remove the `--dry-run` flag. sqlc upload ``` -By uploading your project, you're making sqlc more stable and reliable. Thanks! +By uploading your project, you're making sqlc more stable and reliable. Thanks! \ No newline at end of file diff --git a/internal/bundler/metadata.go b/internal/bundler/metadata.go deleted file mode 100644 index 18d41e9f68..0000000000 --- a/internal/bundler/metadata.go +++ /dev/null @@ -1,16 +0,0 @@ -package bundler - -import ( - "runtime" - - "github.com/sqlc-dev/sqlc/internal/info" -) - -func projectMetadata() ([][2]string, error) { - return [][2]string{ - {"sqlc_version", info.Version}, - {"go_version", runtime.Version()}, - {"goos", runtime.GOOS}, - {"goarch", runtime.GOARCH}, - }, nil -} diff --git a/internal/bundler/multipart.go b/internal/bundler/multipart.go index dd4eed10a1..1336c1a559 100644 --- a/internal/bundler/multipart.go +++ b/internal/bundler/multipart.go @@ -1,16 +1,15 @@ package bundler import ( - "io" - "mime/multipart" "os" "path/filepath" "github.com/sqlc-dev/sqlc/internal/config" + pb "github.com/sqlc-dev/sqlc/internal/quickdb/v1" "github.com/sqlc-dev/sqlc/internal/sql/sqlpath" ) -func writeInputs(w *multipart.Writer, file string, conf *config.Config) error { +func readInputs(file string, conf *config.Config) ([]*pb.File, error) { refs := map[string]struct{}{} refs[filepath.Base(file)] = struct{}{} @@ -18,7 +17,7 @@ func writeInputs(w *multipart.Writer, file string, conf *config.Config) error { for _, paths := range []config.Paths{pkg.Schema, pkg.Queries} { files, err := sqlpath.Glob(paths) if err != nil { - return err + return nil, err } for _, file := range files { refs[file] = struct{}{} @@ -26,55 +25,31 @@ func writeInputs(w *multipart.Writer, file string, conf *config.Config) error { } } + var files []*pb.File for file, _ := range refs { - if err := addPart(w, file); err != nil { - return err - } - } - - params, err := projectMetadata() - if err != nil { - return err - } - params = append(params, [2]string{"project_id", conf.Project.ID}) - for _, val := range params { - if err = w.WriteField(val[0], val[1]); err != nil { - return err + contents, err := os.ReadFile(file) + if err != nil { + return nil, err } + files = append(files, &pb.File{ + Name: file, + Contents: contents, + }) } - return nil + return files, nil } -func addPart(w *multipart.Writer, file string) error { - h, err := os.Open(file) - if err != nil { - return err - } - defer h.Close() - part, err := w.CreateFormFile("inputs", file) - if err != nil { - return err - } - _, err = io.Copy(part, h) - if err != nil { - return err - } - return nil -} - -func writeOutputs(w *multipart.Writer, dir string, output map[string]string) error { +func readOutputs(dir string, output map[string]string) ([]*pb.File, error) { + var files []*pb.File for filename, contents := range output { rel, err := filepath.Rel(dir, filename) if err != nil { - return err - } - part, err := w.CreateFormFile("outputs", rel) - if err != nil { - return err - } - if _, err := io.WriteString(part, contents); err != nil { - return err + return nil, err } + files = append(files, &pb.File{ + Name: rel, + Contents: []byte(contents), + }) } - return nil + return files, nil } diff --git a/internal/bundler/upload.go b/internal/bundler/upload.go index 0d1d508f9a..1152925e02 100644 --- a/internal/bundler/upload.go +++ b/internal/bundler/upload.go @@ -1,16 +1,16 @@ package bundler import ( - "bytes" "context" "fmt" - "io" - "mime/multipart" - "net/http" - "net/http/httputil" "os" + "google.golang.org/protobuf/encoding/protojson" + "github.com/sqlc-dev/sqlc/internal/config" + "github.com/sqlc-dev/sqlc/internal/info" + "github.com/sqlc-dev/sqlc/internal/quickdb" + pb "github.com/sqlc-dev/sqlc/internal/quickdb/v1" ) type Uploader struct { @@ -18,6 +18,7 @@ type Uploader struct { configPath string config *config.Config dir string + client pb.QuickClient } func NewUploader(configPath, dir string, conf *config.Config) *Uploader { @@ -30,35 +31,36 @@ func NewUploader(configPath, dir string, conf *config.Config) *Uploader { } func (up *Uploader) Validate() error { - if up.config.Project.ID == "" { - return fmt.Errorf("project.id is not set") + if up.config.Cloud.Project == "" { + return fmt.Errorf("cloud.project is not set") } if up.token == "" { return fmt.Errorf("SQLC_AUTH_TOKEN environment variable is not set") } + if up.client == nil { + client, err := quickdb.NewClientFromConfig(up.config.Cloud) + if err != nil { + return fmt.Errorf("client init failed: %w", err) + } + up.client = client + } return nil } -func (up *Uploader) buildRequest(ctx context.Context, result map[string]string) (*http.Request, error) { - body := bytes.NewBuffer([]byte{}) - w := multipart.NewWriter(body) - if err := writeInputs(w, up.configPath, up.config); err != nil { - return nil, err - } - if err := writeOutputs(w, up.dir, result); err != nil { - return nil, err - } - if err := w.Close(); err != nil { +func (up *Uploader) buildRequest(ctx context.Context, result map[string]string) (*pb.UploadArchiveRequest, error) { + ins, err := readInputs(up.configPath, up.config) + if err != nil { return nil, err } - req, err := http.NewRequest("POST", "https://api.sqlc.dev/upload", body) + outs, err := readOutputs(up.dir, result) if err != nil { return nil, err } - // Set sqlc-version header - req.Header.Set("Content-Type", w.FormDataContentType()) - req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", up.token)) - return req.WithContext(ctx), nil + return &pb.UploadArchiveRequest{ + SqlcVersion: info.Version, + Inputs: ins, + Outputs: outs, + }, nil } func (up *Uploader) DumpRequestOut(ctx context.Context, result map[string]string) error { @@ -66,11 +68,7 @@ func (up *Uploader) DumpRequestOut(ctx context.Context, result map[string]string if err != nil { return err } - dump, err := httputil.DumpRequest(req, true) - if err != nil { - return err - } - os.Stdout.Write(dump) + fmt.Println(protojson.Format(req)) return nil } @@ -82,18 +80,8 @@ func (up *Uploader) Upload(ctx context.Context, result map[string]string) error if err != nil { return err } - client := &http.Client{} - resp, err := client.Do(req) - if err != nil { - return err - } - if resp.StatusCode >= 400 { - body, err := io.ReadAll(resp.Body) - defer resp.Body.Close() - if err != nil { - return fmt.Errorf("upload error: endpoint returned non-200 status code: %d", resp.StatusCode) - } - return fmt.Errorf("upload error: %d: %s", resp.StatusCode, string(body)) + if _, err := up.client.UploadArchive(ctx, req); err != nil { + return fmt.Errorf("upload error: %w", err) } return nil } diff --git a/internal/config/config.go b/internal/config/config.go index d28ec0e62d..4a17903e6e 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -56,7 +56,6 @@ const ( type Config struct { Version string `json:"version" yaml:"version"` - Project Project `json:"project" yaml:"project"` Cloud Cloud `json:"cloud" yaml:"cloud"` SQL []SQL `json:"sql" yaml:"sql"` Gen Gen `json:"overrides,omitempty" yaml:"overrides"` @@ -64,10 +63,6 @@ type Config struct { Rules []Rule `json:"rules" yaml:"rules"` } -type Project struct { - ID string `json:"id" yaml:"id"` -} - type Database struct { URI string `json:"uri" yaml:"uri"` Managed bool `json:"managed" yaml:"managed"` diff --git a/internal/config/v_one.go b/internal/config/v_one.go index 22906cee82..3d2a53f13a 100644 --- a/internal/config/v_one.go +++ b/internal/config/v_one.go @@ -11,7 +11,6 @@ import ( type V1GenerateSettings struct { Version string `json:"version" yaml:"version"` Cloud Cloud `json:"cloud" yaml:"cloud"` - Project Project `json:"project" yaml:"project"` Packages []v1PackageSettings `json:"packages" yaml:"packages"` Overrides []Override `json:"overrides,omitempty" yaml:"overrides,omitempty"` Rename map[string]string `json:"rename,omitempty" yaml:"rename,omitempty"` @@ -132,7 +131,6 @@ func (c *V1GenerateSettings) ValidateGlobalOverrides() error { func (c *V1GenerateSettings) Translate() Config { conf := Config{ Version: c.Version, - Project: c.Project, Cloud: c.Cloud, Rules: c.Rules, } diff --git a/internal/config/v_one.json b/internal/config/v_one.json index 329b012ff4..e2e8fb03cc 100644 --- a/internal/config/v_one.json +++ b/internal/config/v_one.json @@ -8,14 +8,6 @@ "version": { "const": "1" }, - "project": { - "type": "object", - "properties": { - "id": { - "type": "string" - } - } - }, "cloud": { "type": "object", "properties": { diff --git a/internal/config/v_two.json b/internal/config/v_two.json index 65fdd7bb7e..a77f2616df 100644 --- a/internal/config/v_two.json +++ b/internal/config/v_two.json @@ -8,14 +8,6 @@ "version": { "const": "2" }, - "project": { - "type": "object", - "properties": { - "id": { - "type": "string" - } - } - }, "cloud": { "type": "object", "properties": { diff --git a/internal/quickdb/v1/quickdb.pb.go b/internal/quickdb/v1/quickdb.pb.go index 7bdec99748..34f4e1739c 100755 --- a/internal/quickdb/v1/quickdb.pb.go +++ b/internal/quickdb/v1/quickdb.pb.go @@ -235,6 +235,171 @@ func (*DropEphemeralDatabaseResponse) Descriptor() ([]byte, []int) { return file_proto_quickdb_v1_quickdb_proto_rawDescGZIP(), []int{3} } +type File struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Contents []byte `protobuf:"bytes,2,opt,name=contents,proto3" json:"contents,omitempty"` +} + +func (x *File) Reset() { + *x = File{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_quickdb_v1_quickdb_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *File) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*File) ProtoMessage() {} + +func (x *File) ProtoReflect() protoreflect.Message { + mi := &file_proto_quickdb_v1_quickdb_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 File.ProtoReflect.Descriptor instead. +func (*File) Descriptor() ([]byte, []int) { + return file_proto_quickdb_v1_quickdb_proto_rawDescGZIP(), []int{4} +} + +func (x *File) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *File) GetContents() []byte { + if x != nil { + return x.Contents + } + return nil +} + +type UploadArchiveRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SqlcVersion string `protobuf:"bytes,1,opt,name=sqlc_version,json=sqlcVersion,proto3" json:"sqlc_version,omitempty"` + Inputs []*File `protobuf:"bytes,2,rep,name=inputs,proto3" json:"inputs,omitempty"` + Outputs []*File `protobuf:"bytes,3,rep,name=outputs,proto3" json:"outputs,omitempty"` +} + +func (x *UploadArchiveRequest) Reset() { + *x = UploadArchiveRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_quickdb_v1_quickdb_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UploadArchiveRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UploadArchiveRequest) ProtoMessage() {} + +func (x *UploadArchiveRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_quickdb_v1_quickdb_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 UploadArchiveRequest.ProtoReflect.Descriptor instead. +func (*UploadArchiveRequest) Descriptor() ([]byte, []int) { + return file_proto_quickdb_v1_quickdb_proto_rawDescGZIP(), []int{5} +} + +func (x *UploadArchiveRequest) GetSqlcVersion() string { + if x != nil { + return x.SqlcVersion + } + return "" +} + +func (x *UploadArchiveRequest) GetInputs() []*File { + if x != nil { + return x.Inputs + } + return nil +} + +func (x *UploadArchiveRequest) GetOutputs() []*File { + if x != nil { + return x.Outputs + } + return nil +} + +type UploadArchiveResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Checksum []byte `protobuf:"bytes,1,opt,name=checksum,proto3" json:"checksum,omitempty"` +} + +func (x *UploadArchiveResponse) Reset() { + *x = UploadArchiveResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_quickdb_v1_quickdb_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UploadArchiveResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UploadArchiveResponse) ProtoMessage() {} + +func (x *UploadArchiveResponse) ProtoReflect() protoreflect.Message { + mi := &file_proto_quickdb_v1_quickdb_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 UploadArchiveResponse.ProtoReflect.Descriptor instead. +func (*UploadArchiveResponse) Descriptor() ([]byte, []int) { + return file_proto_quickdb_v1_quickdb_proto_rawDescGZIP(), []int{6} +} + +func (x *UploadArchiveResponse) GetChecksum() []byte { + if x != nil { + return x.Checksum + } + return nil +} + var File_proto_quickdb_v1_quickdb_proto protoreflect.FileDescriptor var file_proto_quickdb_v1_quickdb_proto_rawDesc = []byte{ @@ -262,26 +427,51 @@ var file_proto_quickdb_v1_quickdb_proto_rawDesc = []byte{ 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x49, 0x64, 0x22, 0x1f, 0x0a, 0x1d, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xab, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x69, 0x63, 0x6b, 0x12, 0x92, - 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, - 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x3a, 0x2e, 0x72, 0x65, 0x6d, - 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, - 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x36, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xaf, 0x01, 0x0a, + 0x14, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x71, 0x6c, + 0x63, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x06, 0x69, 0x6e, 0x70, 0x75, + 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, + 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, + 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x06, 0x69, 0x6e, 0x70, 0x75, + 0x74, 0x73, 0x12, 0x3a, 0x0a, 0x07, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, + 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, + 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x07, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x22, 0x33, + 0x0a, 0x15, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x68, 0x65, 0x63, 0x6b, + 0x73, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x68, 0x65, 0x63, 0x6b, + 0x73, 0x75, 0x6d, 0x32, 0xa1, 0x03, 0x0a, 0x05, 0x51, 0x75, 0x69, 0x63, 0x6b, 0x12, 0x92, 0x01, + 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, + 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x3a, 0x2e, 0x72, 0x65, 0x6d, 0x6f, + 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, + 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, + 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, + 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, + 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, + 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x8c, 0x01, 0x0a, 0x15, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, + 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x38, 0x2e, 0x72, + 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, + 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, - 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, - 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x8c, 0x01, 0x0a, 0x15, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, - 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x38, 0x2e, - 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, - 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x45, - 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, - 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, - 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, - 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, + 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x74, 0x0a, 0x0d, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, + 0x76, 0x65, 0x12, 0x30, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, + 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, + 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, + 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, + 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -296,23 +486,30 @@ func file_proto_quickdb_v1_quickdb_proto_rawDescGZIP() []byte { return file_proto_quickdb_v1_quickdb_proto_rawDescData } -var file_proto_quickdb_v1_quickdb_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_proto_quickdb_v1_quickdb_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_proto_quickdb_v1_quickdb_proto_goTypes = []interface{}{ (*CreateEphemeralDatabaseRequest)(nil), // 0: remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseRequest (*CreateEphemeralDatabaseResponse)(nil), // 1: remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseResponse (*DropEphemeralDatabaseRequest)(nil), // 2: remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseRequest (*DropEphemeralDatabaseResponse)(nil), // 3: remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseResponse + (*File)(nil), // 4: remote.sqlc.dev.quickdb.v1.File + (*UploadArchiveRequest)(nil), // 5: remote.sqlc.dev.quickdb.v1.UploadArchiveRequest + (*UploadArchiveResponse)(nil), // 6: remote.sqlc.dev.quickdb.v1.UploadArchiveResponse } var file_proto_quickdb_v1_quickdb_proto_depIdxs = []int32{ - 0, // 0: remote.sqlc.dev.quickdb.v1.Quick.CreateEphemeralDatabase:input_type -> remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseRequest - 2, // 1: remote.sqlc.dev.quickdb.v1.Quick.DropEphemeralDatabase:input_type -> remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseRequest - 1, // 2: remote.sqlc.dev.quickdb.v1.Quick.CreateEphemeralDatabase:output_type -> remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseResponse - 3, // 3: remote.sqlc.dev.quickdb.v1.Quick.DropEphemeralDatabase:output_type -> remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseResponse - 2, // [2:4] is the sub-list for method output_type - 0, // [0:2] 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 + 4, // 0: remote.sqlc.dev.quickdb.v1.UploadArchiveRequest.inputs:type_name -> remote.sqlc.dev.quickdb.v1.File + 4, // 1: remote.sqlc.dev.quickdb.v1.UploadArchiveRequest.outputs:type_name -> remote.sqlc.dev.quickdb.v1.File + 0, // 2: remote.sqlc.dev.quickdb.v1.Quick.CreateEphemeralDatabase:input_type -> remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseRequest + 2, // 3: remote.sqlc.dev.quickdb.v1.Quick.DropEphemeralDatabase:input_type -> remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseRequest + 5, // 4: remote.sqlc.dev.quickdb.v1.Quick.UploadArchive:input_type -> remote.sqlc.dev.quickdb.v1.UploadArchiveRequest + 1, // 5: remote.sqlc.dev.quickdb.v1.Quick.CreateEphemeralDatabase:output_type -> remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseResponse + 3, // 6: remote.sqlc.dev.quickdb.v1.Quick.DropEphemeralDatabase:output_type -> remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseResponse + 6, // 7: remote.sqlc.dev.quickdb.v1.Quick.UploadArchive:output_type -> remote.sqlc.dev.quickdb.v1.UploadArchiveResponse + 5, // [5:8] is the sub-list for method output_type + 2, // [2:5] 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_proto_quickdb_v1_quickdb_proto_init() } @@ -369,6 +566,42 @@ func file_proto_quickdb_v1_quickdb_proto_init() { return nil } } + file_proto_quickdb_v1_quickdb_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*File); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_quickdb_v1_quickdb_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UploadArchiveRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_quickdb_v1_quickdb_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UploadArchiveResponse); 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{ @@ -376,7 +609,7 @@ func file_proto_quickdb_v1_quickdb_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto_quickdb_v1_quickdb_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, @@ -404,6 +637,7 @@ const _ = grpc.SupportPackageIsVersion6 type QuickClient interface { CreateEphemeralDatabase(ctx context.Context, in *CreateEphemeralDatabaseRequest, opts ...grpc.CallOption) (*CreateEphemeralDatabaseResponse, error) DropEphemeralDatabase(ctx context.Context, in *DropEphemeralDatabaseRequest, opts ...grpc.CallOption) (*DropEphemeralDatabaseResponse, error) + UploadArchive(ctx context.Context, in *UploadArchiveRequest, opts ...grpc.CallOption) (*UploadArchiveResponse, error) } type quickClient struct { @@ -432,10 +666,20 @@ func (c *quickClient) DropEphemeralDatabase(ctx context.Context, in *DropEphemer return out, nil } +func (c *quickClient) UploadArchive(ctx context.Context, in *UploadArchiveRequest, opts ...grpc.CallOption) (*UploadArchiveResponse, error) { + out := new(UploadArchiveResponse) + err := c.cc.Invoke(ctx, "/remote.sqlc.dev.quickdb.v1.Quick/UploadArchive", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QuickServer is the server API for Quick service. type QuickServer interface { CreateEphemeralDatabase(context.Context, *CreateEphemeralDatabaseRequest) (*CreateEphemeralDatabaseResponse, error) DropEphemeralDatabase(context.Context, *DropEphemeralDatabaseRequest) (*DropEphemeralDatabaseResponse, error) + UploadArchive(context.Context, *UploadArchiveRequest) (*UploadArchiveResponse, error) } // UnimplementedQuickServer can be embedded to have forward compatible implementations. @@ -448,6 +692,9 @@ func (*UnimplementedQuickServer) CreateEphemeralDatabase(context.Context, *Creat func (*UnimplementedQuickServer) DropEphemeralDatabase(context.Context, *DropEphemeralDatabaseRequest) (*DropEphemeralDatabaseResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DropEphemeralDatabase not implemented") } +func (*UnimplementedQuickServer) UploadArchive(context.Context, *UploadArchiveRequest) (*UploadArchiveResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UploadArchive not implemented") +} func RegisterQuickServer(s *grpc.Server, srv QuickServer) { s.RegisterService(&_Quick_serviceDesc, srv) @@ -489,6 +736,24 @@ func _Quick_DropEphemeralDatabase_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _Quick_UploadArchive_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UploadArchiveRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QuickServer).UploadArchive(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/remote.sqlc.dev.quickdb.v1.Quick/UploadArchive", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QuickServer).UploadArchive(ctx, req.(*UploadArchiveRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Quick_serviceDesc = grpc.ServiceDesc{ ServiceName: "remote.sqlc.dev.quickdb.v1.Quick", HandlerType: (*QuickServer)(nil), @@ -501,6 +766,10 @@ var _Quick_serviceDesc = grpc.ServiceDesc{ MethodName: "DropEphemeralDatabase", Handler: _Quick_DropEphemeralDatabase_Handler, }, + { + MethodName: "UploadArchive", + Handler: _Quick_UploadArchive_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "proto/quickdb/v1/quickdb.proto",