From 51517885ff309277a9c192fe10bb1c60bc2852d6 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sun, 27 Mar 2022 01:17:47 +0300 Subject: [PATCH] small memory fixes Signed-off-by: Vasiliy Tolstov --- .github/renovate.json | 19 ------------------- .github/stale.sh | 13 ------------- registry.go | 4 ++-- table.go | 8 ++++---- watcher.go | 4 ++-- 5 files changed, 8 insertions(+), 40 deletions(-) delete mode 100644 .github/renovate.json delete mode 100755 .github/stale.sh diff --git a/.github/renovate.json b/.github/renovate.json deleted file mode 100644 index 52d2918..0000000 --- a/.github/renovate.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": [ - "config:base" - ], - "packageRules": [ - { - "matchUpdateTypes": ["minor", "patch", "pin", "digest"], - "automerge": true - }, - { - "groupName": "all deps", - "separateMajorMinor": true, - "groupSlug": "all", - "packagePatterns": [ - "*" - ] - } - ] -} diff --git a/.github/stale.sh b/.github/stale.sh deleted file mode 100755 index 8a345c4..0000000 --- a/.github/stale.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -ex - -export PATH=$PATH:$(pwd)/bin -export GO111MODULE=on -export GOBIN=$(pwd)/bin - -#go get github.com/rvflash/goup@v0.4.1 - -#goup -v ./... -#go get github.com/psampaz/go-mod-outdated@v0.6.0 -go list -u -m -mod=mod -json all | go-mod-outdated -update -direct -ci || true - -#go list -u -m -json all | go-mod-outdated -update diff --git a/registry.go b/registry.go index ebdd739..9dfe068 100644 --- a/registry.go +++ b/registry.go @@ -20,11 +20,11 @@ var ( // rtr implements router interface type rtr struct { sync.RWMutex - running bool table *table - opts router.Options exit chan bool initChan chan bool + opts router.Options + running bool } // NewRouter creates new router and returns it diff --git a/table.go b/table.go index 2d3c483..0fb8327 100644 --- a/table.go +++ b/table.go @@ -22,8 +22,8 @@ type table struct { } type route struct { - route router.Route updated time.Time + route router.Route } // newtable creates a new routing table and returns it @@ -129,7 +129,7 @@ func (t *table) Create(r router.Route) error { } // create the route - t.routes[service][sum] = &route{r, time.Now()} + t.routes[service][sum] = &route{updated: time.Now(), route: r} if t.opts.Logger.V(logger.DebugLevel) { t.opts.Logger.Debugf(t.opts.Context, "Router emitting %s for route: %s", router.Create, r.Address) @@ -188,7 +188,7 @@ func (t *table) Update(r router.Route) error { if _, ok := t.routes[service][sum]; !ok { // update the route - t.routes[service][sum] = &route{r, time.Now()} + t.routes[service][sum] = &route{updated: time.Now(), route: r} if t.opts.Logger.V(logger.DebugLevel) { t.opts.Logger.Debugf(t.opts.Context, "Router emitting %s for route: %s", router.Update, r.Address) @@ -198,7 +198,7 @@ func (t *table) Update(r router.Route) error { } // just update the route, but dont emit Update event - t.routes[service][sum] = &route{r, time.Now()} + t.routes[service][sum] = &route{updated: time.Now(), route: r} return nil } diff --git a/watcher.go b/watcher.go index 03af867..bf6a682 100644 --- a/watcher.go +++ b/watcher.go @@ -9,10 +9,10 @@ import ( // tableWatcher implements routing table Watcher type tableWatcher struct { sync.RWMutex - id string - opts router.WatchOptions resChan chan *router.Event done chan struct{} + id string + opts router.WatchOptions } // Next returns the next noticed action taken on table