-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.go
More file actions
36 lines (33 loc) · 1.11 KB
/
helpers.go
File metadata and controls
36 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package waitfor
// Module is a function type that returns resource configuration information.
// It provides a way for resource plugins to declare their supported URL schemes
// and factory function. This enables a plugin-like architecture where resource
// types can be developed and distributed independently.
//
// The function should return:
// - A slice of URL schemes the module supports (e.g., []string{"http", "https"})
// - A ResourceFactory function that can create resource instances from URLs
//
// Example:
//
// func httpModule() ([]string, ResourceFactory) {
// return []string{"http", "https"}, httpResourceFactory
// }
type Module func() ([]string, ResourceFactory)
// Use converts a Module function into a ResourceConfig that can be used
// with New() to register resource types. This provides a convenient way
// to integrate resource plugins into a waitfor Runner.
//
// Example:
//
// runner := waitfor.New(
// waitfor.Use(httpModule),
// waitfor.Use(postgresModule),
// )
func Use(mod Module) ResourceConfig {
scheme, factory := mod()
return ResourceConfig{
Scheme: scheme,
Factory: factory,
}
}