options.go 583 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package ds_sdk
  2. import (
  3. "time"
  4. )
  5. type Option func(opts *Options)
  6. func WithTimeout(timeout time.Duration) Option {
  7. return func(opts *Options) {
  8. opts.timeout = timeout
  9. }
  10. }
  11. func WithSqlResourceDir(sqlResourcesDir string) Option {
  12. return func(opts *Options) {
  13. opts.sqlResourcesDir = sqlResourcesDir
  14. }
  15. }
  16. type DataSourceOption struct {
  17. Name string
  18. Type string
  19. Spec map[string]any
  20. }
  21. type Options struct {
  22. // 必传
  23. token string
  24. baseUrl string
  25. namespace string
  26. dataSource *DataSourceOption
  27. // 选传
  28. timeout time.Duration
  29. sqlResourcesDir string
  30. }