Documentation ¶
Overview ¶
Package xloadtype contains commonly used types for working with xload.Loader.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Endpoint ¶
Endpoint represents a network endpoint It can be used to represent a target host:port pair.
Example ¶
package main import ( "context" "fmt" "github.com/gojekfarm/xtools/xload" xloadtype "github.com/gojekfarm/xtools/xload/type" ) var testValues = map[string]string{ "LISTENER": "[::1]:8080", "ENDPOINT": "example.com:80", } var loader = xload.LoaderFunc(func(ctx context.Context, key string) (string, error) { return testValues[key], nil }) func main() { type Server struct { Endpoint xloadtype.Endpoint `env:"ENDPOINT"` } var srv Server if err := xload.Load(context.Background(), &srv, loader); err != nil { panic(err) } fmt.Println(srv.Endpoint.String()) }
Output: example.com:80
type Listener ¶
Listener represents a network listener, say, a tcp or http listener.
Example ¶
package main import ( "context" "fmt" "github.com/gojekfarm/xtools/xload" xloadtype "github.com/gojekfarm/xtools/xload/type" ) var testValues = map[string]string{ "LISTENER": "[::1]:8080", "ENDPOINT": "example.com:80", } var loader = xload.LoaderFunc(func(ctx context.Context, key string) (string, error) { return testValues[key], nil }) func main() { type Server struct { Listener xloadtype.Listener `env:"LISTENER"` } var srv Server if err := xload.Load(context.Background(), &srv, loader); err != nil { panic(err) } fmt.Println(srv.Listener.String()) }
Output: [::1]:8080
type URL ¶
URL represents a URI reference.
URL is a type alias for url.URL. The general form represented is: [scheme:][//[userinfo@]host][/]path[?query][#fragment] See https://tools.ietf.org/html/rfc3986
Click to show internal directories.
Click to hide internal directories.