Documentation
¶
Overview ¶
The package app is exposing a struct to handle the building and the managing of the different task coming from the package async. This should be used in the main package only.
A quite straightforward usage of this package is when you are implementing an HTTP API and want to expose it. In that case you can use the following example:
package main import ( "github.com/perses/commun/app" ) func main() { // create your api api := newAPI() // then use the app package to start it properly runner := app.NewRunner().WithDefaultHTTPServer("your_api_name") runner.HTTPServerBuilder().APIRegistration(api) // start the application runner.Start() }
Index ¶
- Variables
- type Runner
- func (r *Runner) HTTPServerBuilder() *echo.Builder
- func (r *Runner) SetCronPeriod(period time.Duration) *Runner
- func (r *Runner) SetTimeout(timeout time.Duration) *Runner
- func (r *Runner) Start()
- func (r *Runner) WithCronTasks(t ...interface{}) *Runner
- func (r *Runner) WithDefaultHTTPServer(metricNamespace string) *Runner
- func (r *Runner) WithTaskRunners(t ...async.TaskRunner) *Runner
- func (r *Runner) WithTasks(t ...interface{}) *Runner
Constants ¶
This section is empty.
Variables ¶
var ( // BuildTime is the date when the application has been built. BuildTime string // Version is the current version of the application Version string // Commit is the ID of the commit when the application has been built Commit string )
Functions ¶
This section is empty.
Types ¶
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
func (*Runner) HTTPServerBuilder ¶
func (*Runner) Start ¶
func (r *Runner) Start()
Start will start the application. It is a blocking method and will give back the end once every tasks handled are done.
func (*Runner) WithCronTasks ¶
WithCronTasks is the way to add different task that will be executed periodically at the same frequency. If you want to run different task with different period of time, you probably create by your own an async.TaskRunner using the method async.NewCron. In that case you certainly would prefer to use the method WithTaskRunners instead
func (*Runner) WithDefaultHTTPServer ¶
func (*Runner) WithTaskRunners ¶
func (r *Runner) WithTaskRunners(t ...async.TaskRunner) *Runner