mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-25 21:26:40 +00:00
update my personal library versions (#220)
Signed-off-by: kim (grufwub) <grufwub@gmail.com>
This commit is contained in:
parent
f6492d12d9
commit
635281f133
6
go.mod
6
go.mod
|
@ -3,7 +3,7 @@ module github.com/superseriousbusiness/gotosocial
|
||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.iim.gay/grufwub/go-store v0.4.1
|
git.iim.gay/grufwub/go-store v0.4.2
|
||||||
github.com/ReneKroon/ttlcache v1.7.0
|
github.com/ReneKroon/ttlcache v1.7.0
|
||||||
github.com/buckket/go-blurhash v1.1.0
|
github.com/buckket/go-blurhash v1.1.0
|
||||||
github.com/coreos/go-oidc/v3 v3.0.0
|
github.com/coreos/go-oidc/v3 v3.0.0
|
||||||
|
@ -47,8 +47,8 @@ require (
|
||||||
git.iim.gay/grufwub/go-bytes v0.7.0 // indirect
|
git.iim.gay/grufwub/go-bytes v0.7.0 // indirect
|
||||||
git.iim.gay/grufwub/go-errors v0.2.3 // indirect
|
git.iim.gay/grufwub/go-errors v0.2.3 // indirect
|
||||||
git.iim.gay/grufwub/go-hashenc v0.3.0 // indirect
|
git.iim.gay/grufwub/go-hashenc v0.3.0 // indirect
|
||||||
git.iim.gay/grufwub/go-mutexes v0.5.0 // indirect
|
git.iim.gay/grufwub/go-mutexes v0.5.1 // indirect
|
||||||
git.iim.gay/grufwub/go-nowish v0.3.4 // indirect
|
git.iim.gay/grufwub/go-nowish v0.3.5 // indirect
|
||||||
github.com/aymerick/douceur v0.2.0 // indirect
|
github.com/aymerick/douceur v0.2.0 // indirect
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
|
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
|
12
go.sum
12
go.sum
|
@ -42,12 +42,12 @@ git.iim.gay/grufwub/go-errors v0.2.3/go.mod h1:rfKZpjI7A67zJfzpt5zfwAUMA7gec0EHX
|
||||||
git.iim.gay/grufwub/go-fixedmap v0.1.3/go.mod h1:KB4nV2+NeBMVFvFwpdgsP74AsMiDeX68oD20wiC2S3I=
|
git.iim.gay/grufwub/go-fixedmap v0.1.3/go.mod h1:KB4nV2+NeBMVFvFwpdgsP74AsMiDeX68oD20wiC2S3I=
|
||||||
git.iim.gay/grufwub/go-hashenc v0.3.0 h1:2etpzwoUTPTLvlWZ9u9a+FUCGBcVU37x5zM5XZ0kahQ=
|
git.iim.gay/grufwub/go-hashenc v0.3.0 h1:2etpzwoUTPTLvlWZ9u9a+FUCGBcVU37x5zM5XZ0kahQ=
|
||||||
git.iim.gay/grufwub/go-hashenc v0.3.0/go.mod h1:wjztiGUzaZsEw5kKE6gz/UOFN2cbcDnGiUSUjOLXi4o=
|
git.iim.gay/grufwub/go-hashenc v0.3.0/go.mod h1:wjztiGUzaZsEw5kKE6gz/UOFN2cbcDnGiUSUjOLXi4o=
|
||||||
git.iim.gay/grufwub/go-mutexes v0.5.0 h1:HojjhBWI1ry1TTvijczhm2oQ5CxLbxzihawqYk2Umto=
|
git.iim.gay/grufwub/go-mutexes v0.5.1 h1:HjMUvTCsEWfX8lW7VaYwwkdOA2Bjg8qZjHJAT+cbMBA=
|
||||||
git.iim.gay/grufwub/go-mutexes v0.5.0/go.mod h1:xMhjpEP5UsCuFQD4qCIcq4pJLf7vMXZ56TD/u+wWJ4Y=
|
git.iim.gay/grufwub/go-mutexes v0.5.1/go.mod h1:oCWMmmM+puqoq8y3b2ZEvmazx9XLbcvUIugtMPJswhE=
|
||||||
git.iim.gay/grufwub/go-nowish v0.3.4 h1:VgUzSEO7xJsJFN2HPbPYHT79s3pUkd5Z8hQOPecZzFU=
|
git.iim.gay/grufwub/go-nowish v0.3.5 h1:RBBSPAIZcsqd0QfscMZ55ogNwM+uERoBKKLlNMgFhxs=
|
||||||
git.iim.gay/grufwub/go-nowish v0.3.4/go.mod h1:oII7zlMQMFclFzgmI1qRd7DdQXKNHWcJYnwHFgdgiRI=
|
git.iim.gay/grufwub/go-nowish v0.3.5/go.mod h1:oII7zlMQMFclFzgmI1qRd7DdQXKNHWcJYnwHFgdgiRI=
|
||||||
git.iim.gay/grufwub/go-store v0.4.1 h1:orSqupN2iTm8P0sUpGWlCl6qckM2phkFnsB3TFTo6aQ=
|
git.iim.gay/grufwub/go-store v0.4.2 h1:VjcuyFDW64Pu0fvO9Nww33eLBewrQbtjAKT99YQSJsw=
|
||||||
git.iim.gay/grufwub/go-store v0.4.1/go.mod h1:NaSfOLKNzjj9lUQ0MA/gLGEeRiXhwOx26zR+l/SC9VM=
|
git.iim.gay/grufwub/go-store v0.4.2/go.mod h1:qXeDj6+LlMJsZul3RwP2LLBSOK57Rl/vdWtQdGIbL9g=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
||||||
|
|
24
vendor/git.iim.gay/grufwub/go-mutexes/map.go
vendored
24
vendor/git.iim.gay/grufwub/go-mutexes/map.go
vendored
|
@ -8,15 +8,7 @@
|
||||||
// by key. You do not need to worry about managing the contents of the map,
|
// by key. You do not need to worry about managing the contents of the map,
|
||||||
// only requesting RLock/Lock for keys, and ensuring to call the returned
|
// only requesting RLock/Lock for keys, and ensuring to call the returned
|
||||||
// unlock functions.
|
// unlock functions.
|
||||||
type MutexMap interface {
|
type MutexMap struct {
|
||||||
// Lock acquires a mutex lock for supplied key, returning an Unlock function
|
|
||||||
Lock(key string) (unlock func())
|
|
||||||
|
|
||||||
// RLock acquires a mutex read lock for supplied key, returning an RUnlock function
|
|
||||||
RLock(key string) (runlock func())
|
|
||||||
}
|
|
||||||
|
|
||||||
type mutexMap struct {
|
|
||||||
// NOTE:
|
// NOTE:
|
||||||
// Individual keyed mutexes should ONLY ever
|
// Individual keyed mutexes should ONLY ever
|
||||||
// be locked within the protection of the outer
|
// be locked within the protection of the outer
|
||||||
|
@ -35,7 +27,7 @@ func NewMap(newFn func() RWMutex) MutexMap {
|
||||||
if newFn == nil {
|
if newFn == nil {
|
||||||
newFn = NewRW
|
newFn = NewRW
|
||||||
}
|
}
|
||||||
return &mutexMap{
|
return MutexMap{
|
||||||
mus: make(map[string]RWMutex),
|
mus: make(map[string]RWMutex),
|
||||||
mapMu: sync.Mutex{},
|
mapMu: sync.Mutex{},
|
||||||
pool: sync.Pool{
|
pool: sync.Pool{
|
||||||
|
@ -46,7 +38,7 @@ func NewMap(newFn func() RWMutex) MutexMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mm *mutexMap) evict(key string, mu RWMutex) {
|
func (mm *MutexMap) evict(key string, mu RWMutex) {
|
||||||
// Acquire map lock
|
// Acquire map lock
|
||||||
mm.mapMu.Lock()
|
mm.mapMu.Lock()
|
||||||
|
|
||||||
|
@ -63,21 +55,21 @@ func (mm *mutexMap) evict(key string, mu RWMutex) {
|
||||||
mm.pool.Put(mu)
|
mm.pool.Put(mu)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRLock acquires a mutex read lock for supplied key, returning an RUnlock function
|
// RLock acquires a mutex read lock for supplied key, returning an RUnlock function
|
||||||
func (mm *mutexMap) RLock(key string) func() {
|
func (mm *MutexMap) RLock(key string) func() {
|
||||||
return mm.getLock(key, func(mu RWMutex) func() {
|
return mm.getLock(key, func(mu RWMutex) func() {
|
||||||
return mu.RLock()
|
return mu.RLock()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLock acquires a mutex lock for supplied key, returning an Unlock function
|
// Lock acquires a mutex lock for supplied key, returning an Unlock function
|
||||||
func (mm *mutexMap) Lock(key string) func() {
|
func (mm *MutexMap) Lock(key string) func() {
|
||||||
return mm.getLock(key, func(mu RWMutex) func() {
|
return mm.getLock(key, func(mu RWMutex) func() {
|
||||||
return mu.Lock()
|
return mu.Lock()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mm *mutexMap) getLock(key string, doLock func(RWMutex) func()) func() {
|
func (mm *MutexMap) getLock(key string, doLock func(RWMutex) func()) func() {
|
||||||
// Get map lock
|
// Get map lock
|
||||||
mm.mapMu.Lock()
|
mm.mapMu.Lock()
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ type timeoutMutex struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mu *timeoutMutex) Lock() func() {
|
func (mu *timeoutMutex) Lock() func() {
|
||||||
return mu.LockFunc(func() { panic("timed out") })
|
return mu.LockFunc(func() { panic("lock timed out") })
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mu *timeoutMutex) LockFunc(fn func()) func() {
|
func (mu *timeoutMutex) LockFunc(fn func()) func() {
|
||||||
|
@ -58,7 +58,7 @@ type timeoutRWMutex struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mu *timeoutRWMutex) Lock() func() {
|
func (mu *timeoutRWMutex) Lock() func() {
|
||||||
return mu.LockFunc(func() { panic("timed out") })
|
return mu.LockFunc(func() { panic("lock timed out") })
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mu *timeoutRWMutex) LockFunc(fn func()) func() {
|
func (mu *timeoutRWMutex) LockFunc(fn func()) func() {
|
||||||
|
@ -66,7 +66,7 @@ func (mu *timeoutRWMutex) LockFunc(fn func()) func() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mu *timeoutRWMutex) RLock() func() {
|
func (mu *timeoutRWMutex) RLock() func() {
|
||||||
return mu.RLockFunc(func() { panic("timed out") })
|
return mu.RLockFunc(func() { panic("rlock timed out") })
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mu *timeoutRWMutex) RLockFunc(fn func()) func() {
|
func (mu *timeoutRWMutex) RLockFunc(fn func()) func() {
|
||||||
|
@ -76,7 +76,8 @@ func (mu *timeoutRWMutex) RLockFunc(fn func()) func() {
|
||||||
// timeoutPool provides nowish.Timeout objects for timeout mutexes
|
// timeoutPool provides nowish.Timeout objects for timeout mutexes
|
||||||
var timeoutPool = sync.Pool{
|
var timeoutPool = sync.Pool{
|
||||||
New: func() interface{} {
|
New: func() interface{} {
|
||||||
return nowish.NewTimeout()
|
t := nowish.NewTimeout()
|
||||||
|
return &t
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +89,7 @@ func mutexTimeout(d time.Duration, unlock func(), fn func()) func() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Acquire timeout obj
|
// Acquire timeout obj
|
||||||
t := timeoutPool.Get().(nowish.Timeout)
|
t := timeoutPool.Get().(*nowish.Timeout)
|
||||||
|
|
||||||
// Start the timeout with hook
|
// Start the timeout with hook
|
||||||
t.Start(d, fn)
|
t.Start(d, fn)
|
||||||
|
|
88
vendor/git.iim.gay/grufwub/go-nowish/timeout.go
vendored
88
vendor/git.iim.gay/grufwub/go-nowish/timeout.go
vendored
|
@ -1,57 +1,12 @@
|
||||||
package nowish
|
package nowish
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrTimeoutStarted is returned if a Timeout interface is attempted to be reused while still in operation
|
|
||||||
var ErrTimeoutStarted = errors.New("nowish: timeout already started")
|
|
||||||
|
|
||||||
// timeoutState provides a thread-safe timeout state mechanism
|
|
||||||
type timeoutState uint32
|
|
||||||
|
|
||||||
// start attempts to start the state, must be already reset, returns success
|
|
||||||
func (t *timeoutState) start() bool {
|
|
||||||
return atomic.CompareAndSwapUint32((*uint32)(t), 0, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// stop attempts to stop the state, must already be started, returns success
|
|
||||||
func (t *timeoutState) stop() bool {
|
|
||||||
return atomic.CompareAndSwapUint32((*uint32)(t), 1, 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset is fairly self explanatory
|
|
||||||
func (t *timeoutState) reset() {
|
|
||||||
atomic.StoreUint32((*uint32)(t), 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Timeout provides a reusable structure for enforcing timeouts with a cancel
|
// Timeout provides a reusable structure for enforcing timeouts with a cancel
|
||||||
type Timeout interface {
|
type Timeout struct {
|
||||||
// Start starts the timer with supplied timeout. If timeout is reached before
|
|
||||||
// cancel then supplied timeout hook will be called. Error may be called if
|
|
||||||
// Timeout is already running when this function is called
|
|
||||||
Start(time.Duration, func()) error
|
|
||||||
|
|
||||||
// Cancel cancels the currently running timer. If a cancel is achieved, then
|
|
||||||
// this function will return after the timeout goroutine is finished
|
|
||||||
Cancel()
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewTimeout returns a new Timeout instance
|
|
||||||
func NewTimeout() Timeout {
|
|
||||||
t := &timeout{
|
|
||||||
tk: time.NewTicker(time.Minute),
|
|
||||||
ch: make(chan struct{}),
|
|
||||||
}
|
|
||||||
t.tk.Stop() // don't keep it running
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
// timeout is the Timeout implementation that we force
|
|
||||||
// initialization on via NewTimeout by unexporting it
|
|
||||||
type timeout struct {
|
|
||||||
noCopy noCopy //nolint noCopy because a copy will mess with atomics
|
noCopy noCopy //nolint noCopy because a copy will mess with atomics
|
||||||
|
|
||||||
tk *time.Ticker // tk is the underlying timeout-timer
|
tk *time.Ticker // tk is the underlying timeout-timer
|
||||||
|
@ -59,10 +14,23 @@ type timeout struct {
|
||||||
st timeoutState // st stores the current timeout state (and protects concurrent use)
|
st timeoutState // st stores the current timeout state (and protects concurrent use)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *timeout) Start(d time.Duration, hook func()) error {
|
// NewTimeout returns a new Timeout instance
|
||||||
|
func NewTimeout() Timeout {
|
||||||
|
tk := time.NewTicker(time.Minute)
|
||||||
|
tk.Stop() // don't keep it running
|
||||||
|
return Timeout{
|
||||||
|
tk: tk,
|
||||||
|
ch: make(chan struct{}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start starts the timer with supplied timeout. If timeout is reached before
|
||||||
|
// cancel then supplied timeout hook will be called. Error may be called if
|
||||||
|
// Timeout is already running when this function is called
|
||||||
|
func (t *Timeout) Start(d time.Duration, hook func()) {
|
||||||
// Attempt to acquire start
|
// Attempt to acquire start
|
||||||
if !t.st.start() {
|
if !t.st.start() {
|
||||||
return ErrTimeoutStarted
|
panic("nowish: timeout already started")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the ticker
|
// Start the ticker
|
||||||
|
@ -96,11 +64,11 @@ func (t *timeout) Start(d time.Duration, hook func()) error {
|
||||||
// Finally, reset state
|
// Finally, reset state
|
||||||
t.st.reset()
|
t.st.reset()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *timeout) Cancel() {
|
// Cancel cancels the currently running timer. If a cancel is achieved, then
|
||||||
|
// this function will return after the timeout goroutine is finished
|
||||||
|
func (t *Timeout) Cancel() {
|
||||||
// Attempt to acquire stop
|
// Attempt to acquire stop
|
||||||
if !t.st.stop() {
|
if !t.st.stop() {
|
||||||
return
|
return
|
||||||
|
@ -109,3 +77,21 @@ func (t *timeout) Cancel() {
|
||||||
// Send a cancel signal
|
// Send a cancel signal
|
||||||
t.ch <- struct{}{}
|
t.ch <- struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// timeoutState provides a thread-safe timeout state mechanism
|
||||||
|
type timeoutState uint32
|
||||||
|
|
||||||
|
// start attempts to start the state, must be already reset, returns success
|
||||||
|
func (t *timeoutState) start() bool {
|
||||||
|
return atomic.CompareAndSwapUint32((*uint32)(t), 0, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// stop attempts to stop the state, must already be started, returns success
|
||||||
|
func (t *timeoutState) stop() bool {
|
||||||
|
return atomic.CompareAndSwapUint32((*uint32)(t), 1, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// reset is fairly self explanatory
|
||||||
|
func (t *timeoutState) reset() {
|
||||||
|
atomic.StoreUint32((*uint32)(t), 0)
|
||||||
|
}
|
||||||
|
|
6
vendor/modules.txt
vendored
6
vendor/modules.txt
vendored
|
@ -13,13 +13,13 @@ git.iim.gay/grufwub/go-errors
|
||||||
# git.iim.gay/grufwub/go-hashenc v0.3.0
|
# git.iim.gay/grufwub/go-hashenc v0.3.0
|
||||||
## explicit; go 1.16
|
## explicit; go 1.16
|
||||||
git.iim.gay/grufwub/go-hashenc
|
git.iim.gay/grufwub/go-hashenc
|
||||||
# git.iim.gay/grufwub/go-mutexes v0.5.0
|
# git.iim.gay/grufwub/go-mutexes v0.5.1
|
||||||
## explicit; go 1.16
|
## explicit; go 1.16
|
||||||
git.iim.gay/grufwub/go-mutexes
|
git.iim.gay/grufwub/go-mutexes
|
||||||
# git.iim.gay/grufwub/go-nowish v0.3.4
|
# git.iim.gay/grufwub/go-nowish v0.3.5
|
||||||
## explicit; go 1.16
|
## explicit; go 1.16
|
||||||
git.iim.gay/grufwub/go-nowish
|
git.iim.gay/grufwub/go-nowish
|
||||||
# git.iim.gay/grufwub/go-store v0.4.1
|
# git.iim.gay/grufwub/go-store v0.4.2
|
||||||
## explicit; go 1.16
|
## explicit; go 1.16
|
||||||
git.iim.gay/grufwub/go-store/kv
|
git.iim.gay/grufwub/go-store/kv
|
||||||
git.iim.gay/grufwub/go-store/storage
|
git.iim.gay/grufwub/go-store/storage
|
||||||
|
|
Loading…
Reference in a new issue