Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: replace segmentio/events with segmentio/log #143

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/segmentio/ctlstore

go 1.20
go 1.21

require (
github.com/AlekSi/pointer v1.0.0
Expand All @@ -21,6 +21,7 @@ require (
github.com/segmentio/errors-go v1.0.0
github.com/segmentio/events/v2 v2.3.2
github.com/segmentio/go-sqlite3 v1.14.22-segment
github.com/segmentio/log v0.7.0
github.com/segmentio/stats/v4 v4.6.2
github.com/stretchr/testify v1.8.1
golang.org/x/sync v0.3.0
Expand Down
20 changes: 2 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
github.com/AlekSi/pointer v1.0.0 h1:KWCWzsvFxNLcmM5XmiqHsGTTsuwZMsLFwWF9Y+//bNE=
github.com/AlekSi/pointer v1.0.0/go.mod h1:1kjywbfcPFCmncIxtk6fIEub6LKrfMz3gc5QKVOSOA8=
github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ=
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
github.com/aws/aws-sdk-go v1.37.8 h1:9kywcbuz6vQuTf+FD+U7FshafrHzmqUCjgAEiLuIJ8U=
github.com/aws/aws-sdk-go v1.37.8/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc=
Expand Down Expand Up @@ -113,10 +111,10 @@ github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e h1:uO75wNGioszj
github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e/go.mod h1:tm/wZFQ8e24NYaBGIlnO2WGCAi67re4HHuOm0sftE/M=
github.com/segmentio/go-snakecase v1.1.0 h1:ZJO4SNKKV0MjGOv0LHnixxN5FYv1JKBnVXEuBpwcbQI=
github.com/segmentio/go-snakecase v1.1.0/go.mod h1:jk1miR5MS7Na32PZUykG89Arm+1BUSYhuGR6b7+hJto=
github.com/segmentio/go-sqlite3 v1.12.0 h1:NG3Hdja6V/dDz1uYCapBJCobL+nQLwn6b8Z28DLOU0s=
github.com/segmentio/go-sqlite3 v1.12.0/go.mod h1:ARXycbQZSoCAgThy5syFIL2aXbrKF3tE1DEHfOkxh1g=
github.com/segmentio/go-sqlite3 v1.14.22-segment h1:CMV8jocJ3GqK5ALeFatw5lXANJpusyGAbLMmRWGb61I=
github.com/segmentio/go-sqlite3 v1.14.22-segment/go.mod h1:XD2URsGK8aqqwao9zj/8f/OuOEiFWP45GguwGM906mc=
github.com/segmentio/log v0.7.0 h1:wPGvUjPi4icXYfy7sk57MvN6X13S/T/sCT39wFN4EfU=
github.com/segmentio/log v0.7.0/go.mod h1:lrlHKGKcvVm4/d7hL6rfuPipZqL20ifZL5+zFtUxx3s=
github.com/segmentio/objconv v1.0.1 h1:QjfLzwriJj40JibCV3MGSEiAoXixbp4ybhwfTB8RXOM=
github.com/segmentio/objconv v1.0.1/go.mod h1:auayaH5k3137Cl4SoXTgrzQcuQDmvuVtZgS0fb1Ahys=
github.com/segmentio/stats/v4 v4.6.2 h1:++YfKPTOPTZxE1DvavnpeBvB3hlDIm7IM+ULFzbCxCU=
Expand All @@ -131,11 +129,9 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
Expand All @@ -148,16 +144,12 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -171,22 +163,14 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
12 changes: 6 additions & 6 deletions ldb_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"

"github.com/segmentio/errors-go"
"github.com/segmentio/events/v2"
"github.com/segmentio/log"
"github.com/segmentio/stats/v4"

"github.com/segmentio/ctlstore/pkg/errs"
Expand Down Expand Up @@ -600,7 +600,7 @@ func (reader *LDBReader) watchForLDBs(ctx context.Context, dirPath string, last
case <-ticker.C:
fsLast, err := lookupLastLDBSync(dirPath)
if err != nil {
events.Log("failed checking for last LDB sync: %{error}+v", err)
log.EventLog("failed checking for last LDB sync: %{error}+v", err)
errs.Incr("check-last-ldb-sync")
continue
}
Expand All @@ -609,12 +609,12 @@ func (reader *LDBReader) watchForLDBs(ctx context.Context, dirPath string, last
if fsLast <= last {
continue
}
events.Log("found new LDB (%d > %d), switching...", fsLast, last)
log.EventLog("found new LDB (%d > %d), switching...", fsLast, last)
last = fsLast

err = reader.switchLDB(dirPath, last)
if err != nil {
events.Log("failed switching to new LDB: %{error}+v", err)
log.EventLog("failed switching to new LDB: %{error}+v", err)
errs.Incr("switch-ldb")
}
}
Expand Down Expand Up @@ -677,13 +677,13 @@ func lookupLastLDBSync(dirPath string) (int64, error) {
fields := strings.Split(localPath, "/")

if len(fields) != 2 || fields[1] != ldb.DefaultLDBFilename {
events.Log("ignoring unexpected file in LDB path (%+v)", fields)
log.EventLog("ignoring unexpected file in LDB path (%+v)", fields)
errs.Incr("unexpected-local-file")
return nil
}
timestamp, err := strconv.ParseInt(fields[0], 10, 64)
if err != nil {
events.Log("ignoring file with invalid timestamp in LDB path (%+v)", fields)
log.EventLog("ignoring file with invalid timestamp in LDB path (%+v)", fields)
errs.Incr("invalid-timestamp-local-file")
return nil
}
Expand Down
17 changes: 9 additions & 8 deletions ldb_rotating_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import (
"context"
"errors"
"fmt"
"github.com/segmentio/ctlstore/pkg/errs"
"github.com/segmentio/ctlstore/pkg/globalstats"
"github.com/segmentio/ctlstore/pkg/ldb"
"github.com/segmentio/events/v2"
"github.com/segmentio/stats/v4"
"path"
"strconv"
"sync/atomic"
"time"

"github.com/segmentio/ctlstore/pkg/errs"
"github.com/segmentio/ctlstore/pkg/globalstats"
"github.com/segmentio/ctlstore/pkg/ldb"
"github.com/segmentio/log"
"github.com/segmentio/stats/v4"
)

// LDBRotatingReader reads data from multiple LDBs on a rotating schedule.
Expand Down Expand Up @@ -82,7 +83,7 @@ func rotatingReader(minutesPerRotation RotationPeriod, ldbPaths ...string) (*LDB
}
var r LDBRotatingReader
for _, p := range ldbPaths {
events.Log("Opening ldb %s for reading", p)
log.EventLog("Opening ldb %s for reading", p)
reader, err := newLDBReader(p)
if err != nil {
return nil, err
Expand Down Expand Up @@ -139,14 +140,14 @@ func (r *LDBRotatingReader) rotate(ctx context.Context) {
globalstats.Set("rotating_reader.active", next)
err := r.dbs[last].Close()
if err != nil {
events.Log("failed to close LDBReader for %s on rotation: %{error}v", r.dbs[last].path, err)
log.EventLog("failed to close LDBReader for %s on rotation: %{error}v", r.dbs[last].path, err)
errs.Incr("rotating_reader.closing_ldbreader", stats.T("id", strconv.Itoa(int(last))))
return
}

reader, err := newLDBReader(r.dbs[last].path)
if err != nil {
events.Log("failed to open LDBReader for %s on rotation: %{error}v", r.dbs[last].path, err)
log.EventLog("failed to open LDBReader for %s on rotation: %{error}v", r.dbs[last].path, err)
errs.Incr("rotating_reader.opening_ldbreader",
stats.T("id", strconv.Itoa(int(last))),
stats.T("path", path.Base(r.dbs[last].path)))
Expand Down
4 changes: 2 additions & 2 deletions pkg/changelog/changelog_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"

"github.com/pkg/errors"
"github.com/segmentio/events/v2"
"github.com/segmentio/log"
)

type (
Expand Down Expand Up @@ -45,7 +45,7 @@ func (w *ChangelogWriter) WriteChange(e ChangelogEntry) error {
return errors.Wrap(err, "error marshalling json")
}

events.Debug("changelogWriter.WriteChange: %{family}s.%{table}s => %{key}v",
log.EventDebug("changelogWriter.WriteChange: %{family}s.%{table}s => %{key}v",
e.Family, e.Table, e.Key)

return w.WriteLine.WriteLine(string(bytes))
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/ctlstore-cli/cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"os"
Expand All @@ -25,7 +25,7 @@ var (
func bailResponse(response *http.Response, msg string, args ...interface{}) {
msg = fmt.Sprintf(msg, args...)
// ok to ignore error here
b, _ := ioutil.ReadAll(response.Body)
b, _ := io.ReadAll(response.Body)
respMsg := fmt.Sprintf("server returned [%d]: %s", response.StatusCode, b)
fmt.Fprintln(os.Stderr, fmt.Sprintf("%s: %s", msg, respMsg))
os.Exit(1)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/ctlstore-cli/cmd/writer_limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"text/tabwriter"
Expand Down Expand Up @@ -37,7 +37,7 @@ var cliWriterLimits = &cli.CommandSet{
bailResponse(resp, "could not read limits")
}
var wrl limits.WriterRateLimits
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
if err != nil {
bail("could not read response: %s", err)
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/cmd/ctlstore-mutator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"
"time"
Expand Down Expand Up @@ -111,7 +111,7 @@ func main() {
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
b, _ = ioutil.ReadAll(resp.Body)
b, _ = io.ReadAll(resp.Body)
return fmt.Errorf("could not make mutation request: %d: %s", resp.StatusCode, b)
}
return nil
Expand All @@ -137,7 +137,7 @@ func setup(cfg config, url string) error {
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
b, _ := io.ReadAll(res.Body)
return fmt.Errorf("could register writer: %v: %s", res.StatusCode, b)
}

Expand All @@ -154,7 +154,7 @@ func setup(cfg config, url string) error {
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK && res.StatusCode != http.StatusConflict {
b, _ := ioutil.ReadAll(res.Body)
b, _ := io.ReadAll(res.Body)
return fmt.Errorf("could not make family request: %v: %s", res.StatusCode, b)
}

Expand Down Expand Up @@ -184,7 +184,7 @@ func setup(cfg config, url string) error {
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK && res.StatusCode != http.StatusConflict {
b, _ := ioutil.ReadAll(res.Body)
b, _ := io.ReadAll(res.Body)
return fmt.Errorf("could not make table request: %v: %s", res.StatusCode, b)
}

Expand Down
Loading
Loading