MM-12389 Update segment library to v3 (#11472)

* Update analytics-go dependency

* Migrate from segment library v2 to v3

* Reinclude gorilla/handlers module

* Fix missing module

* Remove reference to outdated analytics module
Этот коммит содержится в:
Claudio Costa
2019-07-04 21:26:41 +02:00
коммит произвёл Christopher Speller
родитель c9e289f828
Коммит d844c52f06
34 изменённых файлов: 1599 добавлений и 459 удалений

53
vendor/github.com/segmentio/analytics-go/executor.go сгенерированный поставляемый Обычный файл
Просмотреть файл

@@ -0,0 +1,53 @@
package analytics
import "sync"
type executor struct {
queue chan func()
mutex sync.Mutex
size int
cap int
}
func newExecutor(cap int) *executor {
e := &executor{
queue: make(chan func(), 1),
cap: cap,
}
go e.loop()
return e
}
func (e *executor) do(task func()) (ok bool) {
e.mutex.Lock()
if e.size != e.cap {
e.queue <- task
e.size++
ok = true
}
e.mutex.Unlock()
return
}
func (e *executor) close() {
close(e.queue)
}
func (e *executor) loop() {
for task := range e.queue {
go e.run(task)
}
}
func (e *executor) run(task func()) {
defer e.done()
task()
}
func (e *executor) done() {
e.mutex.Lock()
e.size--
e.mutex.Unlock()
}