diff options
| author | Shulhan <ms@kilabit.info> | 2021-12-19 14:40:18 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-12-19 14:40:18 +0700 |
| commit | 7ee3e4ea4658e85a40540212b95206b09686feb7 (patch) | |
| tree | babe6a3568f6ead05799e0af31c6d5f6851cfa0b /rescached.go | |
| parent | 7713203c6bd41053599732869a70467a168e4e55 (diff) | |
| download | rescached-7ee3e4ea4658e85a40540212b95206b09686feb7.tar.xz | |
all: refactoring Server initialization
Previously, we initialize the rescached Server by passing the
path to configuration file and initialize the environment inside the
server.
This commit changes it to pass the instance of Environment. The idea
is to allow creating and running rescached Server without creating
configuration file first.
Diffstat (limited to 'rescached.go')
| -rw-r--r-- | rescached.go | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/rescached.go b/rescached.go index af00a1b..a283826 100644 --- a/rescached.go +++ b/rescached.go @@ -26,10 +26,9 @@ const ( // Server implement caching DNS server. type Server struct { - fileConfig string - dns *dns.Server - env *environment - rcWatcher *libio.Watcher + dns *dns.Server + env *Environment + rcWatcher *libio.Watcher httpd *http.Server httpdRunner sync.Once @@ -38,16 +37,13 @@ type Server struct { // // New create and initialize new rescached server. // -func New(fileConfig string) (srv *Server, err error) { - env := loadEnvironment(fileConfig) - +func New(env *Environment) (srv *Server, err error) { if debug.Value >= 1 { fmt.Printf("--- rescached: config: %+v\n", env) } srv = &Server{ - fileConfig: fileConfig, - env: env, + env: env, } err = srv.httpdInit() |
