database_options.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Licensed to the LF AI & Data foundation under one
  2. // or more contributor license agreements. See the NOTICE file
  3. // distributed with this work for additional information
  4. // regarding copyright ownership. The ASF licenses this file
  5. // to you under the Apache License, Version 2.0 (the
  6. // "License"); you may not use this file except in compliance
  7. // with the License. You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. package client
  17. import "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
  18. type UsingDatabaseOption interface {
  19. DbName() string
  20. }
  21. type usingDatabaseNameOpt struct {
  22. dbName string
  23. }
  24. func (opt *usingDatabaseNameOpt) DbName() string {
  25. return opt.dbName
  26. }
  27. func NewUsingDatabaseOption(dbName string) *usingDatabaseNameOpt {
  28. return &usingDatabaseNameOpt{
  29. dbName: dbName,
  30. }
  31. }
  32. // ListDatabaseOption is a builder interface for ListDatabase request.
  33. type ListDatabaseOption interface {
  34. Request() *milvuspb.ListDatabasesRequest
  35. }
  36. type listDatabaseOption struct{}
  37. func (opt *listDatabaseOption) Request() *milvuspb.ListDatabasesRequest {
  38. return &milvuspb.ListDatabasesRequest{}
  39. }
  40. func NewListDatabaseOption() *listDatabaseOption {
  41. return &listDatabaseOption{}
  42. }
  43. type CreateDatabaseOption interface {
  44. Request() *milvuspb.CreateDatabaseRequest
  45. }
  46. type createDatabaseOption struct {
  47. dbName string
  48. }
  49. func (opt *createDatabaseOption) Request() *milvuspb.CreateDatabaseRequest {
  50. return &milvuspb.CreateDatabaseRequest{
  51. DbName: opt.dbName,
  52. }
  53. }
  54. func NewCreateDatabaseOption(dbName string) *createDatabaseOption {
  55. return &createDatabaseOption{
  56. dbName: dbName,
  57. }
  58. }
  59. type DropDatabaseOption interface {
  60. Request() *milvuspb.DropDatabaseRequest
  61. }
  62. type dropDatabaseOption struct {
  63. dbName string
  64. }
  65. func (opt *dropDatabaseOption) Request() *milvuspb.DropDatabaseRequest {
  66. return &milvuspb.DropDatabaseRequest{
  67. DbName: opt.dbName,
  68. }
  69. }
  70. func NewDropDatabaseOption(dbName string) *dropDatabaseOption {
  71. return &dropDatabaseOption{
  72. dbName: dbName,
  73. }
  74. }