From f140dab3b5d392e341895c7736ad70879e8c0eaa Mon Sep 17 00:00:00 2001 From: Songlin Yang Date: Mon, 24 Feb 2025 01:00:12 +0800 Subject: [PATCH] chore(*): auto fix some lint error (#613) --- .github/workflows/pr_build_and_test.yaml | 2 +- .golangci.yaml | 10 ++++------ Makefile | 2 +- cmd/client/cmd.go | 6 ++---- cmd/client/del/cmd_test.go | 5 ++--- cmd/client/deleterange/cmd.go | 3 +-- cmd/client/deleterange/cmd_test.go | 3 +-- cmd/client/get/cmd.go | 4 +--- cmd/client/get/cmd_test.go | 3 +-- cmd/client/list/cmd.go | 3 +-- cmd/client/list/cmd_test.go | 3 +-- cmd/client/notifications/cmd.go | 3 +-- cmd/client/put/cmd.go | 3 +-- cmd/client/rangescan/cmd.go | 3 +-- cmd/client/rangescan/cmd_test.go | 3 +-- cmd/coordinator/cmd.go | 3 +-- cmd/coordinator/cmd_test.go | 3 +-- cmd/health/cmd_test.go | 3 +-- cmd/main.go | 3 +-- cmd/perf/cmd.go | 3 +-- common/callback/once_test.go | 5 +++-- common/client_pool.go | 10 ++++------ common/client_pool_test.go | 3 ++- common/collection/visible_map_test.go | 3 ++- common/container/container.go | 10 ++++------ common/opt_json.go | 1 - coordinator/coordinator_rpc_server.go | 3 +-- coordinator/coordinator_test.go | 3 ++- coordinator/impl/k8s_client.go | 1 - maelstrom/grpc_provider.go | 3 +-- oxia/async_client_impl.go | 3 +-- oxia/options_client.go | 3 +-- oxia/options_list.go | 2 +- oxia/sessions.go | 3 +-- oxia/sync_client_impl_test.go | 3 ++- proto/proto_grpc.go | 1 - server/assignment_dispatcher.go | 1 - server/benchmark_test.go | 3 +-- server/internal_rpc_server.go | 3 +-- server/kv/db.go | 3 +-- server/kv/db_test.go | 2 +- server/kv/kv.go | 4 ++-- server/kv/kv_pebble.go | 8 +++----- server/leader_controller.go | 5 ++--- server/public_rpc_server.go | 6 ++---- server/quorum_ack_tracker.go | 2 +- server/quorum_ack_tracker_test.go | 2 +- server/server.go | 3 +-- server/session.go | 1 - server/session_manager_test.go | 3 +-- server/standalone.go | 3 +-- server/wal/codec/codec.go | 4 ++-- server/wal/codec/v1.go | 7 ++++--- server/wal/codec/v1_test.go | 2 +- server/wal/codec/v2.go | 8 ++++---- server/wal/codec/v2_test.go | 2 +- server/wal/wal_impl.go | 6 ++---- server/wal/wal_ro_segment.go | 5 ++--- server/wal/wal_ro_segment_test.go | 6 +++--- server/wal/wal_rw_segment.go | 4 ++-- server/wal/wal_rw_segment_test.go | 3 ++- 61 files changed, 91 insertions(+), 133 deletions(-) diff --git a/.github/workflows/pr_build_and_test.yaml b/.github/workflows/pr_build_and_test.yaml index 16e19809..924ecccd 100644 --- a/.github/workflows/pr_build_and_test.yaml +++ b/.github/workflows/pr_build_and_test.yaml @@ -62,7 +62,7 @@ jobs: uses: golangci/golangci-lint-action@v6.1.0 with: version: v1.61.0 - args: --timeout=10m + args: --timeout=10m -v - name: Test run: make test diff --git a/.golangci.yaml b/.golangci.yaml index e4a7d8cd..a7c4bbe8 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -12,10 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -run: - skip-dirs: - - pkg/generated - linters: enable: - goimports @@ -34,7 +30,7 @@ linters: - contextcheck - errname - errorlint - - exportloopref + - copyloopvar - gocritic - godot - gomoddirectives @@ -85,7 +81,7 @@ linters-settings: arguments: - maxLitCount: "3" allowStrs: '""' - allowInts: '0,1,2,3,4,5,6,7,8,9,10,11,16,17,20,22,32,64,100,128,1000,1024,0644,0755,0600' + allowInts: "0,1,2,3,4,5,6,7,8,9,10,11,16,17,20,22,32,64,100,128,1000,1024,0644,0755,0600" allowFloats: "0.0,0.,0.5,0.50,0.95,0.99,0.999,1.0,1.,2.0,2.,80.0,100.0" ignoreFuncs: 'slog\.*,metrics\.*,fmt\.*' - name: cognitive-complexity @@ -133,6 +129,8 @@ issues: fix: true max-same-issues: 3 max-issues-per-linter: 50 + exclude-dirs: + - pkg/generated # include: # - "EXC0012" # - "EXC0014" diff --git a/Makefile b/Makefile index a0d5a880..4f7c022f 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ test: build lint: #brew install golangci-lint - golangci-lint run + golangci-lint run -v clean: rm -f bin/oxia bin/oxia-maelstrom diff --git a/cmd/client/cmd.go b/cmd/client/cmd.go index 7a85e072..de375da5 100644 --- a/cmd/client/cmd.go +++ b/cmd/client/cmd.go @@ -17,20 +17,18 @@ package client import ( "fmt" - "github.com/streamnative/oxia/cmd/client/deleterange" - "github.com/spf13/cobra" - "github.com/streamnative/oxia/oxia" - "github.com/streamnative/oxia/cmd/client/common" "github.com/streamnative/oxia/cmd/client/del" + "github.com/streamnative/oxia/cmd/client/deleterange" "github.com/streamnative/oxia/cmd/client/get" "github.com/streamnative/oxia/cmd/client/list" "github.com/streamnative/oxia/cmd/client/notifications" "github.com/streamnative/oxia/cmd/client/put" "github.com/streamnative/oxia/cmd/client/rangescan" oxiacommon "github.com/streamnative/oxia/common" + "github.com/streamnative/oxia/oxia" ) var ( diff --git a/cmd/client/del/cmd_test.go b/cmd/client/del/cmd_test.go index e7e477e2..da1a9bd4 100644 --- a/cmd/client/del/cmd_test.go +++ b/cmd/client/del/cmd_test.go @@ -20,12 +20,11 @@ import ( "testing" "github.com/pkg/errors" + "github.com/spf13/cobra" + "github.com/stretchr/testify/assert" "github.com/streamnative/oxia/cmd/client/common" "github.com/streamnative/oxia/oxia" - - "github.com/spf13/cobra" - "github.com/stretchr/testify/assert" ) func runCmd(cmd *cobra.Command, args string) (string, error) { diff --git a/cmd/client/deleterange/cmd.go b/cmd/client/deleterange/cmd.go index d72a6e8d..d5b588b7 100644 --- a/cmd/client/deleterange/cmd.go +++ b/cmd/client/deleterange/cmd.go @@ -19,9 +19,8 @@ import ( "github.com/spf13/cobra" - "github.com/streamnative/oxia/oxia" - "github.com/streamnative/oxia/cmd/client/common" + "github.com/streamnative/oxia/oxia" ) var ( diff --git a/cmd/client/deleterange/cmd_test.go b/cmd/client/deleterange/cmd_test.go index 8e3dc85d..ce59f415 100644 --- a/cmd/client/deleterange/cmd_test.go +++ b/cmd/client/deleterange/cmd_test.go @@ -22,9 +22,8 @@ import ( "github.com/spf13/cobra" "github.com/stretchr/testify/assert" - "github.com/streamnative/oxia/oxia" - "github.com/streamnative/oxia/cmd/client/common" + "github.com/streamnative/oxia/oxia" ) func runCmd(cmd *cobra.Command, args string, stdin string) (string, error) { diff --git a/cmd/client/get/cmd.go b/cmd/client/get/cmd.go index 08878281..d6dff9aa 100644 --- a/cmd/client/get/cmd.go +++ b/cmd/client/get/cmd.go @@ -19,12 +19,10 @@ import ( "time" "github.com/pkg/errors" - - "github.com/streamnative/oxia/oxia" - "github.com/spf13/cobra" "github.com/streamnative/oxia/cmd/client/common" + "github.com/streamnative/oxia/oxia" ) var ( diff --git a/cmd/client/get/cmd_test.go b/cmd/client/get/cmd_test.go index 7dcfe343..f475b5f7 100644 --- a/cmd/client/get/cmd_test.go +++ b/cmd/client/get/cmd_test.go @@ -22,9 +22,8 @@ import ( "github.com/spf13/cobra" "github.com/stretchr/testify/assert" - "github.com/streamnative/oxia/oxia" - "github.com/streamnative/oxia/cmd/client/common" + "github.com/streamnative/oxia/oxia" ) func runCmd(cmd *cobra.Command, args string, stdin string) (string, error) { diff --git a/cmd/client/list/cmd.go b/cmd/client/list/cmd.go index 5bc1b816..d46a7ca1 100644 --- a/cmd/client/list/cmd.go +++ b/cmd/client/list/cmd.go @@ -19,9 +19,8 @@ import ( "github.com/spf13/cobra" - "github.com/streamnative/oxia/oxia" - "github.com/streamnative/oxia/cmd/client/common" + "github.com/streamnative/oxia/oxia" ) var ( diff --git a/cmd/client/list/cmd_test.go b/cmd/client/list/cmd_test.go index 64525172..ac6dd80a 100644 --- a/cmd/client/list/cmd_test.go +++ b/cmd/client/list/cmd_test.go @@ -22,9 +22,8 @@ import ( "github.com/spf13/cobra" "github.com/stretchr/testify/assert" - "github.com/streamnative/oxia/oxia" - "github.com/streamnative/oxia/cmd/client/common" + "github.com/streamnative/oxia/oxia" ) func runCmd(cmd *cobra.Command, args string, stdin string) (string, error) { diff --git a/cmd/client/notifications/cmd.go b/cmd/client/notifications/cmd.go index 7c93fd85..cbd7ed38 100644 --- a/cmd/client/notifications/cmd.go +++ b/cmd/client/notifications/cmd.go @@ -17,11 +17,10 @@ package notifications import ( "log/slog" - "github.com/streamnative/oxia/oxia" - "github.com/spf13/cobra" "github.com/streamnative/oxia/cmd/client/common" + "github.com/streamnative/oxia/oxia" ) var Cmd = &cobra.Command{ diff --git a/cmd/client/put/cmd.go b/cmd/client/put/cmd.go index 1995c452..cb9a1ac1 100644 --- a/cmd/client/put/cmd.go +++ b/cmd/client/put/cmd.go @@ -22,9 +22,8 @@ import ( "github.com/spf13/cobra" - "github.com/streamnative/oxia/oxia" - "github.com/streamnative/oxia/cmd/client/common" + "github.com/streamnative/oxia/oxia" ) var ( diff --git a/cmd/client/rangescan/cmd.go b/cmd/client/rangescan/cmd.go index 2b7d42e7..42ff9b6c 100644 --- a/cmd/client/rangescan/cmd.go +++ b/cmd/client/rangescan/cmd.go @@ -18,11 +18,10 @@ import ( "context" "time" - "github.com/streamnative/oxia/oxia" - "github.com/spf13/cobra" "github.com/streamnative/oxia/cmd/client/common" + "github.com/streamnative/oxia/oxia" ) var ( diff --git a/cmd/client/rangescan/cmd_test.go b/cmd/client/rangescan/cmd_test.go index c2746a97..952f36d6 100644 --- a/cmd/client/rangescan/cmd_test.go +++ b/cmd/client/rangescan/cmd_test.go @@ -22,9 +22,8 @@ import ( "github.com/spf13/cobra" "github.com/stretchr/testify/assert" - "github.com/streamnative/oxia/oxia" - "github.com/streamnative/oxia/cmd/client/common" + "github.com/streamnative/oxia/oxia" ) func runCmd(cmd *cobra.Command, args string, stdin string) (string, error) { diff --git a/cmd/coordinator/cmd.go b/cmd/coordinator/cmd.go index cce039bb..44d452b9 100644 --- a/cmd/coordinator/cmd.go +++ b/cmd/coordinator/cmd.go @@ -19,10 +19,9 @@ import ( "log/slog" "strings" + "github.com/fsnotify/fsnotify" "github.com/mitchellh/mapstructure" "github.com/pkg/errors" - - "github.com/fsnotify/fsnotify" "github.com/spf13/cobra" "github.com/spf13/viper" diff --git a/cmd/coordinator/cmd_test.go b/cmd/coordinator/cmd_test.go index e5eda395..f0249d6e 100644 --- a/cmd/coordinator/cmd_test.go +++ b/cmd/coordinator/cmd_test.go @@ -19,9 +19,8 @@ import ( "strings" "testing" - "github.com/spf13/viper" - "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/stretchr/testify/assert" "gopkg.in/yaml.v3" diff --git a/cmd/health/cmd_test.go b/cmd/health/cmd_test.go index 3e895fd4..b0db433d 100644 --- a/cmd/health/cmd_test.go +++ b/cmd/health/cmd_test.go @@ -18,8 +18,6 @@ import ( "fmt" "testing" - "github.com/streamnative/oxia/server/auth" - "github.com/stretchr/testify/assert" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -28,6 +26,7 @@ import ( "google.golang.org/grpc/status" "github.com/streamnative/oxia/common/container" + "github.com/streamnative/oxia/server/auth" ) func TestHealthCmd(t *testing.T) { diff --git a/cmd/main.go b/cmd/main.go index 53fbb8e2..bfd0e491 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -19,8 +19,6 @@ import ( "fmt" "os" - "github.com/streamnative/oxia/cmd/wal" - "github.com/spf13/cobra" "go.uber.org/automaxprocs/maxprocs" @@ -31,6 +29,7 @@ import ( "github.com/streamnative/oxia/cmd/perf" "github.com/streamnative/oxia/cmd/server" "github.com/streamnative/oxia/cmd/standalone" + "github.com/streamnative/oxia/cmd/wal" "github.com/streamnative/oxia/common" ) diff --git a/cmd/perf/cmd.go b/cmd/perf/cmd.go index 996031d4..10d502b7 100644 --- a/cmd/perf/cmd.go +++ b/cmd/perf/cmd.go @@ -19,11 +19,10 @@ import ( "fmt" "io" - "github.com/streamnative/oxia/oxia" - "github.com/spf13/cobra" "github.com/streamnative/oxia/common" + "github.com/streamnative/oxia/oxia" "github.com/streamnative/oxia/perf" ) diff --git a/common/callback/once_test.go b/common/callback/once_test.go index 91553f87..5a4a629c 100644 --- a/common/callback/once_test.go +++ b/common/callback/once_test.go @@ -28,11 +28,12 @@ package callback import ( - "github.com/pkg/errors" - "github.com/stretchr/testify/assert" "sync" "sync/atomic" "testing" + + "github.com/pkg/errors" + "github.com/stretchr/testify/assert" ) func Test_Once_Complete_Concurrent(t *testing.T) { diff --git a/common/client_pool.go b/common/client_pool.go index 63605472..c7781e15 100644 --- a/common/client_pool.go +++ b/common/client_pool.go @@ -17,24 +17,22 @@ package common import ( "context" "crypto/tls" - "google.golang.org/grpc/keepalive" "io" "log/slog" "strings" "sync" "time" - "github.com/streamnative/oxia/oxia/auth" - - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/credentials/insecure" - grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus" "github.com/pkg/errors" "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/health/grpc_health_v1" + "google.golang.org/grpc/keepalive" "google.golang.org/grpc/peer" + "github.com/streamnative/oxia/oxia/auth" "github.com/streamnative/oxia/proto" ) diff --git a/common/client_pool_test.go b/common/client_pool_test.go index 2ea07de7..ac32b81b 100644 --- a/common/client_pool_test.go +++ b/common/client_pool_test.go @@ -15,8 +15,9 @@ package common import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestClientPool_GetActualAddress(t *testing.T) { diff --git a/common/collection/visible_map_test.go b/common/collection/visible_map_test.go index 5fa4ed8e..710b066e 100644 --- a/common/collection/visible_map_test.go +++ b/common/collection/visible_map_test.go @@ -15,8 +15,9 @@ package collection import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestVisibleMap(t *testing.T) { diff --git a/common/container/container.go b/common/container/container.go index 443752f2..f2ae1536 100644 --- a/common/container/container.go +++ b/common/container/container.go @@ -17,22 +17,20 @@ package container import ( "context" "crypto/tls" - "google.golang.org/grpc/keepalive" "io" "log/slog" "net" "os" "time" - "github.com/streamnative/oxia/server/auth" - - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/credentials/insecure" - grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus" "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/keepalive" "github.com/streamnative/oxia/common" + "github.com/streamnative/oxia/server/auth" ) const ( diff --git a/common/opt_json.go b/common/opt_json.go index a93ce04a..1ad691d9 100644 --- a/common/opt_json.go +++ b/common/opt_json.go @@ -19,7 +19,6 @@ import ( "reflect" "github.com/mitchellh/mapstructure" - "github.com/pkg/errors" ) diff --git a/coordinator/coordinator_rpc_server.go b/coordinator/coordinator_rpc_server.go index 173e0fd6..adf29b6e 100644 --- a/coordinator/coordinator_rpc_server.go +++ b/coordinator/coordinator_rpc_server.go @@ -17,13 +17,12 @@ package coordinator import ( "crypto/tls" - "github.com/streamnative/oxia/server/auth" - "google.golang.org/grpc" "google.golang.org/grpc/health" "google.golang.org/grpc/health/grpc_health_v1" "github.com/streamnative/oxia/common/container" + "github.com/streamnative/oxia/server/auth" ) type rpcServer struct { diff --git a/coordinator/coordinator_test.go b/coordinator/coordinator_test.go index 2f0550ce..ac33ad91 100644 --- a/coordinator/coordinator_test.go +++ b/coordinator/coordinator_test.go @@ -16,8 +16,9 @@ package coordinator import ( "encoding/json" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestCoordinator_MarshalingError(t *testing.T) { diff --git a/coordinator/impl/k8s_client.go b/coordinator/impl/k8s_client.go index 14a96c21..e7371582 100644 --- a/coordinator/impl/k8s_client.go +++ b/coordinator/impl/k8s_client.go @@ -21,7 +21,6 @@ import ( "os" pb "google.golang.org/protobuf/proto" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/maelstrom/grpc_provider.go b/maelstrom/grpc_provider.go index 5ec6ccb4..b56faab6 100644 --- a/maelstrom/grpc_provider.go +++ b/maelstrom/grpc_provider.go @@ -23,8 +23,6 @@ import ( "os" "sync" - "github.com/streamnative/oxia/server/auth" - "github.com/pkg/errors" "google.golang.org/grpc" "google.golang.org/grpc/metadata" @@ -32,6 +30,7 @@ import ( "github.com/streamnative/oxia/common/container" "github.com/streamnative/oxia/proto" + "github.com/streamnative/oxia/server/auth" ) const ( diff --git a/oxia/async_client_impl.go b/oxia/async_client_impl.go index 67841a0b..8e543e9d 100644 --- a/oxia/async_client_impl.go +++ b/oxia/async_client_impl.go @@ -24,10 +24,9 @@ import ( "go.uber.org/multierr" "golang.org/x/exp/slices" - "github.com/streamnative/oxia/common/compare" - "github.com/streamnative/oxia/common" commonbatch "github.com/streamnative/oxia/common/batch" + "github.com/streamnative/oxia/common/compare" "github.com/streamnative/oxia/oxia/internal" "github.com/streamnative/oxia/oxia/internal/batch" "github.com/streamnative/oxia/oxia/internal/metrics" diff --git a/oxia/options_client.go b/oxia/options_client.go index 2ec7e1bb..55e56286 100644 --- a/oxia/options_client.go +++ b/oxia/options_client.go @@ -18,8 +18,6 @@ import ( "crypto/tls" "time" - "github.com/streamnative/oxia/oxia/auth" - "github.com/google/uuid" "github.com/pkg/errors" "go.opentelemetry.io/otel" @@ -28,6 +26,7 @@ import ( "go.uber.org/multierr" "github.com/streamnative/oxia/common" + "github.com/streamnative/oxia/oxia/auth" ) const ( diff --git a/oxia/options_list.go b/oxia/options_list.go index a3add2fb..19260eb1 100644 --- a/oxia/options_list.go +++ b/oxia/options_list.go @@ -47,7 +47,7 @@ func (u *useIndex) applyRangeScan(opts *rangeScanOptions) { } // UseIndex let the users specify a different index to follow for the -// Note: The returned list will contain they primary keys of the records +// Note: The returned list will contain they primary keys of the records. func UseIndex(indexName string) ListOption { return &useIndex{indexName} } diff --git a/oxia/sessions.go b/oxia/sessions.go index f90f7428..0aa1bae1 100644 --- a/oxia/sessions.go +++ b/oxia/sessions.go @@ -22,9 +22,8 @@ import ( "sync" "time" - "go.uber.org/multierr" - "github.com/cenkalti/backoff/v4" + "go.uber.org/multierr" "google.golang.org/grpc/status" "github.com/streamnative/oxia/common" diff --git a/oxia/sync_client_impl_test.go b/oxia/sync_client_impl_test.go index 6fec5645..95f0ac1b 100644 --- a/oxia/sync_client_impl_test.go +++ b/oxia/sync_client_impl_test.go @@ -17,12 +17,13 @@ package oxia import ( "context" "fmt" - "github.com/streamnative/oxia/server" "log/slog" "strings" "testing" "github.com/stretchr/testify/assert" + + "github.com/streamnative/oxia/server" ) type neverCompleteAsyncClient struct { diff --git a/proto/proto_grpc.go b/proto/proto_grpc.go index c63614b9..97439080 100644 --- a/proto/proto_grpc.go +++ b/proto/proto_grpc.go @@ -19,7 +19,6 @@ import ( "github.com/planetscale/vtprotobuf/codec/grpc" "google.golang.org/grpc/encoding" - _ "google.golang.org/grpc/encoding/proto" pb "google.golang.org/protobuf/proto" ) diff --git a/server/assignment_dispatcher.go b/server/assignment_dispatcher.go index e7ab7802..dad2a612 100644 --- a/server/assignment_dispatcher.go +++ b/server/assignment_dispatcher.go @@ -64,7 +64,6 @@ type shardAssignmentDispatcher struct { activeClientsGauge metrics.Gauge } -//nolint:revive func (s *shardAssignmentDispatcher) RegisterForUpdates(req *proto.ShardAssignmentsRequest, clientStream Client) error { s.Lock() diff --git a/server/benchmark_test.go b/server/benchmark_test.go index ea21dc79..3a19247c 100644 --- a/server/benchmark_test.go +++ b/server/benchmark_test.go @@ -24,9 +24,8 @@ import ( "testing" "time" - "github.com/streamnative/oxia/oxia" - "github.com/streamnative/oxia/common" + "github.com/streamnative/oxia/oxia" "github.com/streamnative/oxia/perf" ) diff --git a/server/internal_rpc_server.go b/server/internal_rpc_server.go index 9aa7a887..7830f0ec 100644 --- a/server/internal_rpc_server.go +++ b/server/internal_rpc_server.go @@ -21,8 +21,6 @@ import ( "io" "log/slog" - "github.com/streamnative/oxia/server/auth" - "github.com/pkg/errors" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -34,6 +32,7 @@ import ( "github.com/streamnative/oxia/common" "github.com/streamnative/oxia/common/container" "github.com/streamnative/oxia/proto" + "github.com/streamnative/oxia/server/auth" ) type internalRpcServer struct { diff --git a/server/kv/db.go b/server/kv/db.go index 74860b4c..7bbacbcf 100644 --- a/server/kv/db.go +++ b/server/kv/db.go @@ -23,10 +23,9 @@ import ( "sync/atomic" "time" - pb "google.golang.org/protobuf/proto" - "github.com/pkg/errors" "go.uber.org/multierr" + pb "google.golang.org/protobuf/proto" "github.com/streamnative/oxia/common" "github.com/streamnative/oxia/common/metrics" diff --git a/server/kv/db_test.go b/server/kv/db_test.go index 55a38ad3..ed11c3e8 100644 --- a/server/kv/db_test.go +++ b/server/kv/db_test.go @@ -16,11 +16,11 @@ package kv import ( "fmt" - "github.com/google/uuid" "os" "path" "testing" + "github.com/google/uuid" "github.com/stretchr/testify/assert" pb "google.golang.org/protobuf/proto" diff --git a/server/kv/kv.go b/server/kv/kv.go index 2c2e259c..cf3969f3 100644 --- a/server/kv/kv.go +++ b/server/kv/kv.go @@ -17,9 +17,9 @@ package kv import ( "io" - "github.com/streamnative/oxia/proto" - "github.com/pkg/errors" + + "github.com/streamnative/oxia/proto" ) var ( diff --git a/server/kv/kv_pebble.go b/server/kv/kv_pebble.go index 37ef0f77..9f4d11e7 100644 --- a/server/kv/kv_pebble.go +++ b/server/kv/kv_pebble.go @@ -16,7 +16,6 @@ package kv import ( "fmt" - "golang.org/x/net/context" "io" "log/slog" "os" @@ -24,16 +23,15 @@ import ( "sync/atomic" "time" - "github.com/cockroachdb/pebble/bloom" - - "github.com/streamnative/oxia/common/compare" - "github.com/cockroachdb/pebble" + "github.com/cockroachdb/pebble/bloom" "github.com/cockroachdb/pebble/vfs" "github.com/pkg/errors" "go.uber.org/multierr" + "golang.org/x/net/context" "github.com/streamnative/oxia/common" + "github.com/streamnative/oxia/common/compare" "github.com/streamnative/oxia/common/metrics" ) diff --git a/server/leader_controller.go b/server/leader_controller.go index 53b18053..da8418c5 100644 --- a/server/leader_controller.go +++ b/server/leader_controller.go @@ -17,19 +17,18 @@ package server import ( "context" "fmt" - "github.com/streamnative/oxia/common/callback" "io" "log/slog" "sync" "time" - "google.golang.org/grpc/status" - "github.com/pkg/errors" "go.uber.org/multierr" + "google.golang.org/grpc/status" pb "google.golang.org/protobuf/proto" "github.com/streamnative/oxia/common" + "github.com/streamnative/oxia/common/callback" "github.com/streamnative/oxia/common/metrics" "github.com/streamnative/oxia/proto" "github.com/streamnative/oxia/server/kv" diff --git a/server/public_rpc_server.go b/server/public_rpc_server.go index 39755ccf..b9f65712 100644 --- a/server/public_rpc_server.go +++ b/server/public_rpc_server.go @@ -20,18 +20,16 @@ import ( "io" "log/slog" - "google.golang.org/grpc/metadata" - - "github.com/streamnative/oxia/server/auth" - "github.com/pkg/errors" "google.golang.org/grpc" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/encoding/protowire" "github.com/streamnative/oxia/common" "github.com/streamnative/oxia/common/container" "github.com/streamnative/oxia/proto" + "github.com/streamnative/oxia/server/auth" ) const ( diff --git a/server/quorum_ack_tracker.go b/server/quorum_ack_tracker.go index f99ca87f..8f2169d0 100644 --- a/server/quorum_ack_tracker.go +++ b/server/quorum_ack_tracker.go @@ -17,12 +17,12 @@ package server import ( "context" "errors" - "github.com/streamnative/oxia/common/callback" "io" "sync" "sync/atomic" "github.com/streamnative/oxia/common" + "github.com/streamnative/oxia/common/callback" "github.com/streamnative/oxia/server/util" ) diff --git a/server/quorum_ack_tracker_test.go b/server/quorum_ack_tracker_test.go index 388a792a..558e1a7c 100644 --- a/server/quorum_ack_tracker_test.go +++ b/server/quorum_ack_tracker_test.go @@ -16,12 +16,12 @@ package server import ( "context" - "github.com/streamnative/oxia/common" "testing" "time" "github.com/stretchr/testify/assert" + "github.com/streamnative/oxia/common" "github.com/streamnative/oxia/server/wal" ) diff --git a/server/server.go b/server/server.go index e51bc6d1..2a55bdb6 100644 --- a/server/server.go +++ b/server/server.go @@ -19,13 +19,12 @@ import ( "log/slog" "time" - "github.com/streamnative/oxia/server/auth" - "go.uber.org/multierr" "google.golang.org/grpc/health" "github.com/streamnative/oxia/common/container" "github.com/streamnative/oxia/common/metrics" + "github.com/streamnative/oxia/server/auth" "github.com/streamnative/oxia/server/kv" "github.com/streamnative/oxia/server/wal" ) diff --git a/server/session.go b/server/session.go index e3a4dfc4..adf9b8f1 100644 --- a/server/session.go +++ b/server/session.go @@ -24,7 +24,6 @@ import ( "time" "github.com/streamnative/oxia/common" - "github.com/streamnative/oxia/proto" ) diff --git a/server/session_manager_test.go b/server/session_manager_test.go index 26c93c27..f377c88a 100644 --- a/server/session_manager_test.go +++ b/server/session_manager_test.go @@ -21,14 +21,13 @@ import ( "testing" "time" - "github.com/streamnative/oxia/server/wal" - "github.com/stretchr/testify/assert" pb "google.golang.org/protobuf/proto" "github.com/streamnative/oxia/common" "github.com/streamnative/oxia/proto" "github.com/streamnative/oxia/server/kv" + "github.com/streamnative/oxia/server/wal" ) func TestSessionKey(t *testing.T) { diff --git a/server/standalone.go b/server/standalone.go index c31db9f0..daf7b8fb 100644 --- a/server/standalone.go +++ b/server/standalone.go @@ -19,14 +19,13 @@ import ( "log/slog" "path/filepath" - "github.com/streamnative/oxia/server/auth" - "go.uber.org/multierr" "github.com/streamnative/oxia/common" "github.com/streamnative/oxia/common/container" "github.com/streamnative/oxia/common/metrics" "github.com/streamnative/oxia/proto" + "github.com/streamnative/oxia/server/auth" "github.com/streamnative/oxia/server/kv" "github.com/streamnative/oxia/server/wal" ) diff --git a/server/wal/codec/codec.go b/server/wal/codec/codec.go index 45506e0d..4beb34a3 100644 --- a/server/wal/codec/codec.go +++ b/server/wal/codec/codec.go @@ -117,7 +117,7 @@ type Codec interface { // - buf: the byte slice containing the raw data. // - startFileOffset: the starting file offset from which recovery begins. // - baseEntryOffset: the base offset for the index entries, used to adjust entry offsets. - // - commitOffset: a pointer to the commit offset, which is using for auto-discard uncommited corruption data + // - commitOffset: a pointer to the commit offset, which is using for auto-discard uncommitted corruption data // // Returns: // - index: the recovered index data as a byte slice. @@ -165,7 +165,7 @@ func ReadInt(b []byte, offset uint32) uint32 { return binary.BigEndian.Uint32(b[offset : offset+4]) } -// Index buf +// Index buf. var bufferPool = sync.Pool{} const initialIndexBufferCapacity = 16 * 1024 diff --git a/server/wal/codec/v1.go b/server/wal/codec/v1.go index ed7dd263..e0e3e3e8 100644 --- a/server/wal/codec/v1.go +++ b/server/wal/codec/v1.go @@ -16,10 +16,11 @@ package codec import ( "encoding/binary" - "github.com/pkg/errors" - "go.uber.org/multierr" "io" "os" + + "github.com/pkg/errors" + "go.uber.org/multierr" ) // Txn File: @@ -33,7 +34,7 @@ import ( // +----------------+----------------+----------------+ // | Index(4 Bytes) | Index(4 Bytes) | ... | // +----------------+----------------+----------------+ -// Index: The file offset index +// Index: The file offset index. var _ Codec = &V1{} const v1PayloadSizeLen uint32 = 4 diff --git a/server/wal/codec/v1_test.go b/server/wal/codec/v1_test.go index 7188a154..26570cdc 100644 --- a/server/wal/codec/v1_test.go +++ b/server/wal/codec/v1_test.go @@ -16,11 +16,11 @@ package codec import ( "encoding/binary" - "github.com/google/uuid" "os" "path" "testing" + "github.com/google/uuid" "github.com/stretchr/testify/assert" ) diff --git a/server/wal/codec/v2.go b/server/wal/codec/v2.go index 187cb60d..7e713a21 100644 --- a/server/wal/codec/v2.go +++ b/server/wal/codec/v2.go @@ -16,12 +16,12 @@ package codec import ( "encoding/binary" - "go.uber.org/multierr" "io" "log/slog" "os" "github.com/pkg/errors" + "go.uber.org/multierr" "github.com/streamnative/oxia/server/util/crc" ) @@ -40,7 +40,7 @@ import ( // | CRC(4Bytes) | Index(4B) | Index(4B) | ... | // +--------------+-----------+-----------+-----+ // CRC: 32bit hash computed over the payload using CRC. -// Index: The file offset index +// Index: The file offset index. var _ Codec = &V2{} const v2PayloadSizeLen uint32 = 4 @@ -217,8 +217,8 @@ func (v *V2) RecoverIndex(buf []byte, startFileOffset uint32, baseEntryOffset in // data corruption if errors.Is(err, ErrOffsetOutOfBounds) || errors.Is(err, ErrDataCorrupted) { if commitOffset != nil && currentEntryOffset > *commitOffset { - // uncommited data corruption, simply discard it - slog.Warn("discard the corrupted uncommited data.", + // uncommitted data corruption, simply discard it + slog.Warn("discard the corrupted uncommitted data.", slog.Int64("entryId", currentEntryOffset), slog.Any("error", err)) break } diff --git a/server/wal/codec/v2_test.go b/server/wal/codec/v2_test.go index f5ba2d50..7b884411 100644 --- a/server/wal/codec/v2_test.go +++ b/server/wal/codec/v2_test.go @@ -17,11 +17,11 @@ package codec import ( "bytes" "encoding/binary" - "github.com/google/uuid" "os" "path" "testing" + "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/streamnative/oxia/server/util/crc" diff --git a/server/wal/wal_impl.go b/server/wal/wal_impl.go index fbeff330..87f25077 100644 --- a/server/wal/wal_impl.go +++ b/server/wal/wal_impl.go @@ -23,17 +23,15 @@ import ( "sync/atomic" "time" - "golang.org/x/exp/slices" - - "github.com/streamnative/oxia/server/wal/codec" - "github.com/pkg/errors" "go.uber.org/multierr" + "golang.org/x/exp/slices" pb "google.golang.org/protobuf/proto" "github.com/streamnative/oxia/common" "github.com/streamnative/oxia/common/metrics" "github.com/streamnative/oxia/proto" + "github.com/streamnative/oxia/server/wal/codec" ) type walFactory struct { diff --git a/server/wal/wal_ro_segment.go b/server/wal/wal_ro_segment.go index 41c8dff7..07601ab9 100644 --- a/server/wal/wal_ro_segment.go +++ b/server/wal/wal_ro_segment.go @@ -23,13 +23,12 @@ import ( "sync" "time" - "github.com/streamnative/oxia/server/wal/codec" - "github.com/edsrzf/mmap-go" "github.com/pkg/errors" "go.uber.org/multierr" "github.com/streamnative/oxia/common" + "github.com/streamnative/oxia/server/wal/codec" ) func segmentPath(basePath string, firstOffset int64) string { @@ -329,7 +328,7 @@ func (r *readOnlySegmentsGroup) PollHighestSegment() (common.RefCount[ReadOnlySe defer r.Unlock() if r.allSegments.Empty() { - return nil, nil // nolint: nilnil + return nil, nil //nolint:nilnil } offset, _ := r.allSegments.Max() diff --git a/server/wal/wal_ro_segment_test.go b/server/wal/wal_ro_segment_test.go index ae93cde1..77e92134 100644 --- a/server/wal/wal_ro_segment_test.go +++ b/server/wal/wal_ro_segment_test.go @@ -16,13 +16,13 @@ package wal import ( "fmt" - "github.com/google/uuid" "os" "testing" - "github.com/streamnative/oxia/server/wal/codec" - + "github.com/google/uuid" "github.com/stretchr/testify/assert" + + "github.com/streamnative/oxia/server/wal/codec" ) func TestReadOnlySegment(t *testing.T) { diff --git a/server/wal/wal_rw_segment.go b/server/wal/wal_rw_segment.go index 122dba51..8542bd73 100644 --- a/server/wal/wal_rw_segment.go +++ b/server/wal/wal_rw_segment.go @@ -20,11 +20,11 @@ import ( "sync" "time" - "github.com/streamnative/oxia/server/wal/codec" - "github.com/edsrzf/mmap-go" "github.com/pkg/errors" "go.uber.org/multierr" + + "github.com/streamnative/oxia/server/wal/codec" ) type ReadWriteSegment interface { diff --git a/server/wal/wal_rw_segment_test.go b/server/wal/wal_rw_segment_test.go index 4d4a3120..e46f8d91 100644 --- a/server/wal/wal_rw_segment_test.go +++ b/server/wal/wal_rw_segment_test.go @@ -16,10 +16,11 @@ package wal import ( "encoding/binary" - "github.com/streamnative/oxia/server/wal/codec" "testing" "github.com/stretchr/testify/assert" + + "github.com/streamnative/oxia/server/wal/codec" ) func TestReadWriteSegment(t *testing.T) {