Timer for tasks, servers autoupdating and other.

Added Timer - great package which will make periodic tasks to work.
Timer exposes "taskDone" event, which can be triggered when
task ends it's execution.

Added first periodic task - servers information updating. By
default it will execute every 10 minutes. Configurable thru
options.

Added new options pane: Servers updating. It controls all aspects
of servers updating thing. Master server address, servers
autoupdating checkbox and autoupdate timeout values are exposed
for now.

We're now on on 0.2.0-devel :).

Fixes #29.
This commit is contained in:
2016-12-13 08:01:48 +05:00
parent 2997abf1aa
commit 4020d52c03
11 changed files with 392 additions and 17 deletions

View File

@@ -23,6 +23,7 @@ import (
"github.com/pztrn/urtrator/eventer"
"github.com/pztrn/urtrator/launcher"
"github.com/pztrn/urtrator/requester"
"github.com/pztrn/urtrator/timer"
// Github
"github.com/mattn/go-gtk/gtk"
@@ -45,6 +46,8 @@ type Context struct {
Launcher *launcher.Launcher
// Requester, which requests server's information.
Requester *requester.Requester
// Timer.
Timer *timer.Timer
}
func (ctx *Context) Close() error {
@@ -100,10 +103,15 @@ func (ctx *Context) initializeLauncher() {
}
func (ctx *Context) initializeRequester() {
ctx.Requester = requester.New(ctx.Cache, ctx.Eventer)
ctx.Requester = requester.New(ctx.Cache, ctx.Eventer, ctx.Cfg, ctx.Timer)
ctx.Requester.Initialize()
}
func (ctx *Context) initializeTimer() {
ctx.Timer = timer.New(ctx.Eventer, ctx.Cfg)
ctx.Timer.Initialize()
}
func (ctx *Context) Initialize() {
fmt.Println("Initializing application context...")
ctx.initializeColorizer()
@@ -112,5 +120,6 @@ func (ctx *Context) Initialize() {
ctx.initializeEventer()
ctx.initializeCache()
ctx.initializeLauncher()
ctx.initializeTimer()
ctx.initializeRequester()
}