leaps: github.com/Jeffail/leaps/lib/util/service Index | Files | Directories

package service

import "github.com/Jeffail/leaps/lib/util/service"

Package util provides a few bootstrapping utilities for golang services, and a consistent API to wrap third parties libraries for things such as stats aggregation and logging.


Package Files


func Bootstrap Uses

func Bootstrap(configPtr interface{}, defaultConfigPaths ...string) bool

Bootstrap - bootstraps the configuration loading, parsing and reporting for a service through cmd flags. The argument configPtr should be a pointer to a serializable configuration object with all default values.

configPtr - should be a pointer to a config struct, which contains default values and should be populated with a users config values if applicable. For an example look at the stats and logger files.

defaultConfigPaths - if there are known standard configuration paths then you can list them here, if the user neglects to specify a config then bootstrap will iterate these paths and read the first one that exists, if any.

Bootstrap allows a user to do the following: - Print version and build info and exit - Load an optional configuration file (supports JSON, YAML) - Print the config file (supports JSON, YAML) and exit

NOTE: The user may request a version and build time stamp, in which case Bootstrap will print the values of util.Version and util.DateBuilt. To populate those values you must run go build with the following:

-ldflags "-X github.com/jeffail/util.version $(VERSION) \

-X github.com/jeffail/util.dateBuilt $(DATE)"

Returns a flag indicating whether the service should continue or not.


logPackage log - Some utilities for logging and stats aggregation/pushing.
metricsPackage metrics - Create a type for aggregating and propagating metrics to various services based on configuration.

Package service imports 7 packages (graph). Updated 2018-02-28. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).