| 123456789101112131415161718192021222324252627282930313233343536 |
- package ds_sdk
- import "time"
- type DataSource struct {
- Name string
- Type string
- Spec string
- }
- type Options struct {
- // 必传
- token string
- baseUrl string
- namespace string
- // 选传
- timeout time.Duration
- dataSourceMap map[string]DataSource
- }
- type Option func(opts *Options)
- func WithTimeout(timeout time.Duration) Option {
- return func(opts *Options) {
- opts.timeout = timeout
- }
- }
- func WithDataSource(dataSources []DataSource) Option {
- return func(opts *Options) {
- for _, dataSource := range dataSources {
- opts.dataSourceMap[dataSource.Name] = dataSource
- }
- }
- }
|