()
| 11 | ) |
| 12 | |
| 13 | func Example_providers() { |
| 14 | if os.Getenv("ELASTICSEARCH_ADDR") == "" { |
| 15 | fmt.Println("set ELASTICSEARCH_ADDR to run example") |
| 16 | return |
| 17 | } |
| 18 | c := core.New( |
| 19 | core.WithInline("log.level", "none"), |
| 20 | core.WithInline("es.default.url", strings.Split(os.Getenv("ELASTICSEARCH_ADDR"), ",")), |
| 21 | ) |
| 22 | c.ProvideEssentials() |
| 23 | c.Provide(otes.Providers(otes.WithClientConstructor(func(args otes.ClientArgs) (*elastic.Client, error) { |
| 24 | return elastic.NewClient(elastic.SetURL(args.Conf.URL...), elastic.SetGzip(true)) |
| 25 | }))) |
| 26 | c.Invoke(func(esClient *elastic.Client) { |
| 27 | running := esClient.IsRunning() |
| 28 | fmt.Println(running) |
| 29 | }) |
| 30 | // Output: |
| 31 | // true |
| 32 | } |
nothing calls this directly
no test coverage detected