Huge refactor regarding concurrency.

Now we have pooler which will pool connections (like pinging),
so there will be no timeouts due to "we have launched 100000 goroutines".

Reworked all code to use events (see Eventer). Still more work about
this to go.

Maybe more fixes I forgot.
This commit is contained in:
2016-10-06 13:55:03 +05:00
parent dd41537106
commit f37dd3adfd
9 changed files with 521 additions and 219 deletions

View File

@@ -14,6 +14,7 @@ import (
"fmt"
// local
"github.com/pztrn/urtrator/cache"
"github.com/pztrn/urtrator/colorizer"
"github.com/pztrn/urtrator/configuration"
"github.com/pztrn/urtrator/database"
@@ -26,6 +27,8 @@ import (
)
type Context struct {
// Caching.
Cache *cache.Cache
// Colors parser and prettifier.
Colorizer *colorizer.Colorizer
// Configuration.
@@ -43,12 +46,18 @@ type Context struct {
func (ctx *Context) Close() {
fmt.Println("Closing URTrator...")
ctx.Cache.FlushServers()
ctx.Database.Close()
// At last, close main window.
gtk.MainQuit()
}
func (ctx *Context) initializeCache() {
ctx.Cache = cache.New(ctx.Database, ctx.Eventer)
ctx.Cache.Initialize()
}
func (ctx *Context) initializeColorizer() {
ctx.Colorizer = colorizer.New()
ctx.Colorizer.Initialize()
@@ -76,7 +85,7 @@ func (ctx *Context) initializeLauncher() {
}
func (ctx *Context) initializeRequester() {
ctx.Requester = requester.New()
ctx.Requester = requester.New(ctx.Cache, ctx.Eventer)
ctx.Requester.Initialize()
}
@@ -86,6 +95,7 @@ func (ctx *Context) Initialize() {
ctx.initializeConfig()
ctx.initializeDatabase()
ctx.initializeEventer()
ctx.initializeCache()
ctx.initializeLauncher()
ctx.initializeRequester()
}