diff --git a/go.mod b/go.mod index cc0252c8123b9a69fff481f15fca0597d0b3de46..7ce417d13c56c772ca061d4d92e3ce9d70d5b821 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.22.1 require ( git.autistici.org/ai3/go-common v0.0.0-20240906100150-439608162088 git.autistici.org/id/usermetadb v0.0.0-20230817075814-ec109f54aa90 - github.com/bradfitz/gomemcache v0.0.0-20230124162541-5f7a7d875746 + github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 github.com/cenkalti/backoff/v4 v4.3.0 github.com/coreos/go-systemd/v22 v22.5.0 github.com/go-ldap/ldap/v3 v3.4.8 diff --git a/go.sum b/go.sum index d41ff7b87c4f39a43622e70ea13a3be8036e49fa..fc5cfe528225cf08a2cb945c7dd073e84804509c 100644 --- a/go.sum +++ b/go.sum @@ -137,6 +137,8 @@ github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8 github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/bradfitz/gomemcache v0.0.0-20230124162541-5f7a7d875746 h1:wAIE/kN63Oig1DdOzN7O+k4AbFh2cCJoKMFXrwRJtzk= github.com/bradfitz/gomemcache v0.0.0-20230124162541-5f7a7d875746/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA= +github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 h1:N7oVaKyGp8bttX0bfZGmcGkjz7DLQXhAn3DNd3T0ous= +github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874/go.mod h1:r5xuitiExdLAJ09PR7vBVENGvp4ZuTBeWTGtxuX3K+c= github.com/caarlos0/ctrlc v1.0.0/go.mod h1:CdXpj4rmq0q/1Eb44M9zi2nKB0QraNKuRGYGrrHhcQw= github.com/campoy/unique v0.0.0-20180121183637-88950e537e7e/go.mod h1:9IOqJGCPMSc6E5ydlp5NIonxObaeu/Iub/X03EKPVYo= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= diff --git a/vendor/github.com/bradfitz/gomemcache/AUTHORS b/vendor/github.com/bradfitz/gomemcache/AUTHORS new file mode 100644 index 0000000000000000000000000000000000000000..86ca62074dcb28ad23b443ffef42ae926f895b20 --- /dev/null +++ b/vendor/github.com/bradfitz/gomemcache/AUTHORS @@ -0,0 +1,9 @@ +The following people & companies are the copyright holders of this +package. Feel free to add to this list if you or your employer cares, +otherwise it's implicit from the git log. + +Authors: + +- Brad Fitzpatrick +- Google, Inc. (from Googlers contributing) +- Anybody else in the git log. diff --git a/vendor/github.com/bradfitz/gomemcache/memcache/memcache.go b/vendor/github.com/bradfitz/gomemcache/memcache/memcache.go index b536d38401a032ede6b06397fe59ca5f3b10c509..b2ebacd2ab24310ccb86d096dcb0f765bc22d016 100644 --- a/vendor/github.com/bradfitz/gomemcache/memcache/memcache.go +++ b/vendor/github.com/bradfitz/gomemcache/memcache/memcache.go @@ -1,5 +1,5 @@ /* -Copyright 2011 Google Inc. +Copyright 2011 The gomemcache AUTHORS Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -20,11 +20,11 @@ package memcache import ( "bufio" "bytes" + "context" "errors" "fmt" "io" "net" - "strconv" "strings" "sync" @@ -65,7 +65,7 @@ var ( const ( // DefaultTimeout is the default socket read/write timeout. - DefaultTimeout = 100 * time.Millisecond + DefaultTimeout = 500 * time.Millisecond // DefaultMaxIdleConns is the default maximum number of idle connections // kept for any single address. @@ -132,6 +132,14 @@ func NewFromSelector(ss ServerSelector) *Client { // Client is a memcache client. // It is safe for unlocked use by multiple concurrent goroutines. type Client struct { + // DialContext connects to the address on the named network using the + // provided context. + // + // To connect to servers using TLS (memcached running with "--enable-ssl"), + // use a DialContext func that uses tls.Dialer.DialContext. See this + // package's tests as an example. + DialContext func(ctx context.Context, network, address string) (net.Conn, error) + // Timeout specifies the socket read/write timeout. // If zero, DefaultTimeout is used. Timeout time.Duration @@ -167,8 +175,11 @@ type Item struct { // Zero means the Item has no expiration time. Expiration int32 - // Compare and swap ID. - casid uint64 + // CasID is the compare and swap ID. + // + // It's populated by get requests and then the same value is + // required for a CompareAndSwap request to succeed. + CasID uint64 } // conn is a connection to a server. @@ -255,7 +266,18 @@ func (cte *ConnectTimeoutError) Error() string { } func (c *Client) dial(addr net.Addr) (net.Conn, error) { - nc, err := net.DialTimeout(addr.Network(), addr.String(), c.netTimeout()) + ctx, cancel := context.WithTimeout(context.Background(), c.netTimeout()) + defer cancel() + + dialerContext := c.DialContext + if dialerContext == nil { + dialer := net.Dialer{ + Timeout: c.netTimeout(), + } + dialerContext = dialer.DialContext + } + + nc, err := dialerContext(ctx, addr.Network(), addr.String()) if err == nil { return nc, nil } @@ -520,7 +542,7 @@ func parseGetResponse(r *bufio.Reader, cb func(*Item)) error { // It does not read the bytes of the item. func scanGetResponseLine(line []byte, it *Item) (size int, err error) { pattern := "VALUE %s %d %d %d\r\n" - dest := []interface{}{&it.Key, &it.Flags, &size, &it.casid} + dest := []interface{}{&it.Key, &it.Flags, &size, &it.CasID} if bytes.Count(line, space) == 3 { pattern = "VALUE %s %d %d\r\n" dest = dest[:3] @@ -603,7 +625,7 @@ func (c *Client) populateOne(rw *bufio.ReadWriter, verb string, item *Item) erro var err error if verb == "cas" { _, err = fmt.Fprintf(rw, "%s %s %d %d %d %d\r\n", - verb, item.Key, item.Flags, item.Expiration, len(item.Value), item.casid) + verb, item.Key, item.Flags, item.Expiration, len(item.Value), item.CasID) } else { _, err = fmt.Fprintf(rw, "%s %s %d %d %d\r\n", verb, item.Key, item.Flags, item.Expiration, len(item.Value)) diff --git a/vendor/github.com/bradfitz/gomemcache/memcache/selector.go b/vendor/github.com/bradfitz/gomemcache/memcache/selector.go index 89ad81e0d830652f42b935bdfc9fca17685bde3e..964dbdb6a2e9f2e11dc123a44d9063bc3740881b 100644 --- a/vendor/github.com/bradfitz/gomemcache/memcache/selector.go +++ b/vendor/github.com/bradfitz/gomemcache/memcache/selector.go @@ -1,5 +1,5 @@ /* -Copyright 2011 Google Inc. +Copyright 2011 The gomemcache AUTHORS Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/vendor/modules.txt b/vendor/modules.txt index 81ba21f9780d6da9240b17df0d1521dfab52de15..0afd6970b81b7fd1853a533dbc9e85de5a440e94 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -28,8 +28,8 @@ github.com/beorn7/perks/quantile github.com/boombuler/barcode github.com/boombuler/barcode/qr github.com/boombuler/barcode/utils -# github.com/bradfitz/gomemcache v0.0.0-20230124162541-5f7a7d875746 -## explicit; go 1.12 +# github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 +## explicit; go 1.18 github.com/bradfitz/gomemcache/memcache # github.com/cenkalti/backoff/v4 v4.3.0 ## explicit; go 1.18