From 212f150233c812ff4ed098a2c8a273a02dc06150 Mon Sep 17 00:00:00 2001 From: "abericyang@gmail.com" Date: Thu, 19 Sep 2019 15:15:12 +0800 Subject: [PATCH] make consul rm --- .gitignore | 1 + .travis.yml | 2 -- Makefile | 4 ++++ log.go | 8 ++------ pool.go | 58 ----------------------------------------------------- 5 files changed, 7 insertions(+), 66 deletions(-) delete mode 100644 pool.go diff --git a/.gitignore b/.gitignore index 7876879..a63d633 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ gen### Go template /example/ /profile.coverprofile /overalls.coverprofile +/coverage.txt diff --git a/.travis.yml b/.travis.yml index a707610..04233a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,12 +14,10 @@ before_install: - go get github.com/go-playground/overalls # overalls能够支持到各级子目录 - go get github.com/mattn/goveralls # 是coveralls对golang的测试覆盖率支持命令 - go get github.com/smartystreets/goconvey # 测试工具 - - go get github.com/hashicorp/consul # consul测试 script: - make checkTravis go: - - 1.11.x - 1.12.x - master \ No newline at end of file diff --git a/Makefile b/Makefile index a87497b..7e090f0 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,10 @@ veralls: @echo "goveralls" goveralls -coverprofile=overalls.coverprofile -service=travis-ci -repotoken $(COVERALLS_TOKEN) +traviscodecovtest: + @echo "travistest" + go test -race -coverprofile=coverage.txt -covermode=atomic + test: @echo "test" go test -v -cover $(PKGS_WITH_OUT_EXAMPLES) \ No newline at end of file diff --git a/log.go b/log.go index e7ecebb..db2d8e7 100644 --- a/log.go +++ b/log.go @@ -354,9 +354,7 @@ func (l *LogCommon) logStandard(file, levelName, msg string, line int, ok bool, if nil == l.files { return } - _ = pool().submitField(func(timeString, fileString, stackString, levelName, msg string, level Level, fields ...*Field) { - l.logFile(timeString, fileString, stackString, levelName, msg, level, fields...) - }, timeString, fileString, stackString, levelName, msg, level, fields...) + go l.logFile(timeString, fileString, stackString, levelName, msg, level, fields...) } // logFile 将日志内容输入文件中存储 @@ -428,9 +426,7 @@ func (l *LogCommon) useFiled(level Level, printString string) (fd *filed, err er if err = l.checkFiled(level, fd, int64(len(printString)), false); nil != err { return } - err = pool().submit(func() { - fd.running() - }) + go fd.running() return } } diff --git a/pool.go b/pool.go deleted file mode 100644 index 99b1341..0000000 --- a/pool.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2019. aberic - All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gnomon - -import ( - "github.com/panjf2000/ants" - "sync" -) - -var ( - pc *poolCommon - oncePool sync.Once -) - -func pool() *poolCommon { - oncePool.Do(func() { - pc = &poolCommon{} - pc.init(1000) - }) - return pc -} - -type poolCommon struct { - pool *ants.Pool - once sync.Once -} - -func (p *poolCommon) init(size int) { - p.once.Do(func() { - p.pool, _ = ants.NewPool(size) - }) -} - -func (p *poolCommon) submit(task func()) error { - return p.pool.Submit(func() { - task() - }) -} - -func (p *poolCommon) submitField( - task func(timeString, fileString, stackString, levelName, msg string, level Level, fields ...*Field), - timeString, fileString, stackString, levelName, msg string, level Level, fields ...*Field) error { - return p.pool.Submit(func() { - task(timeString, fileString, stackString, levelName, msg, level, fields...) - }) -}