Skip to content

Commit

Permalink
fix: package structure of error interceptor (vanus-labs#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
ifplusor authored May 6, 2023
1 parent 7f8f352 commit 1fe5c19
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 20 deletions.
2 changes: 1 addition & 1 deletion client/internal/vanus/net/connection/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"google.golang.org/grpc/credentials/insecure"

// first-party libraries.
"github.com/vanus-labs/vanus/internal/primitive/interceptor/errinterceptor"
errinterceptor "github.com/vanus-labs/vanus/pkg/grpc/interceptor/errors"
)

func Connect(ctx context.Context, endpoint string) (*grpc.ClientConn, error) {
Expand Down
8 changes: 6 additions & 2 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package main

import (
// standard libraries.
"context"
"flag"
"fmt"
Expand All @@ -23,25 +24,28 @@ import (
"runtime/debug"
"sync"

// third-party libraries.
recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/reflection"
"google.golang.org/grpc/status"

"github.com/vanus-labs/vanus/internal/controller/tenant"
// first-party libraries.
"github.com/vanus-labs/vanus/observability"
"github.com/vanus-labs/vanus/observability/log"
"github.com/vanus-labs/vanus/observability/metrics"
errinterceptor "github.com/vanus-labs/vanus/pkg/grpc/interceptor/errors"
"github.com/vanus-labs/vanus/pkg/util/signal"
ctrlpb "github.com/vanus-labs/vanus/proto/pkg/controller"

// this project.
"github.com/vanus-labs/vanus/internal/controller"
"github.com/vanus-labs/vanus/internal/controller/eventbus"
"github.com/vanus-labs/vanus/internal/controller/member"
"github.com/vanus-labs/vanus/internal/controller/tenant"
"github.com/vanus-labs/vanus/internal/controller/trigger"
"github.com/vanus-labs/vanus/internal/primitive/interceptor/errinterceptor"
"github.com/vanus-labs/vanus/internal/primitive/interceptor/memberinterceptor"
"github.com/vanus-labs/vanus/internal/primitive/vanus"
)
Expand Down
4 changes: 2 additions & 2 deletions cmd/root/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"flag"
"fmt"
"github.com/vanus-labs/vanus/internal/controller/root"
"net"
"os"
"runtime/debug"
Expand All @@ -34,12 +33,13 @@ import (
"github.com/vanus-labs/vanus/observability"
"github.com/vanus-labs/vanus/observability/log"
"github.com/vanus-labs/vanus/observability/metrics"
errinterceptor "github.com/vanus-labs/vanus/pkg/grpc/interceptor/errors"
"github.com/vanus-labs/vanus/pkg/util/signal"
ctrlpb "github.com/vanus-labs/vanus/proto/pkg/controller"

"github.com/vanus-labs/vanus/internal/controller"
"github.com/vanus-labs/vanus/internal/controller/member"
"github.com/vanus-labs/vanus/internal/primitive/interceptor/errinterceptor"
"github.com/vanus-labs/vanus/internal/controller/root"
"github.com/vanus-labs/vanus/internal/primitive/interceptor/memberinterceptor"
"github.com/vanus-labs/vanus/internal/primitive/vanus"
)
Expand Down
18 changes: 10 additions & 8 deletions internal/gateway/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,25 @@ import (
"github.com/vanus-labs/vanus/client/pkg/api"
"github.com/vanus-labs/vanus/client/pkg/option"
"github.com/vanus-labs/vanus/client/pkg/policy"
"github.com/vanus-labs/vanus/internal/convert"
"github.com/vanus-labs/vanus/internal/gateway/auth"
"github.com/vanus-labs/vanus/internal/primitive"
"github.com/vanus-labs/vanus/internal/primitive/authorization"
"github.com/vanus-labs/vanus/internal/primitive/interceptor/errinterceptor"
"github.com/vanus-labs/vanus/internal/primitive/vanus"
"github.com/vanus-labs/vanus/internal/trigger/filter"
"github.com/vanus-labs/vanus/internal/trigger/transform"
"github.com/vanus-labs/vanus/observability/log"
"github.com/vanus-labs/vanus/observability/metrics"
"github.com/vanus-labs/vanus/observability/tracing"
"github.com/vanus-labs/vanus/pkg/cluster"
"github.com/vanus-labs/vanus/pkg/errors"
errinterceptor "github.com/vanus-labs/vanus/pkg/grpc/interceptor/errors"
"github.com/vanus-labs/vanus/proto/pkg/cloudevents"
ctrlpb "github.com/vanus-labs/vanus/proto/pkg/controller"
metapb "github.com/vanus-labs/vanus/proto/pkg/meta"
proxypb "github.com/vanus-labs/vanus/proto/pkg/proxy"

// this project.
"github.com/vanus-labs/vanus/internal/convert"
"github.com/vanus-labs/vanus/internal/gateway/auth"
"github.com/vanus-labs/vanus/internal/primitive"
"github.com/vanus-labs/vanus/internal/primitive/authorization"
"github.com/vanus-labs/vanus/internal/primitive/vanus"
"github.com/vanus-labs/vanus/internal/trigger/filter"
"github.com/vanus-labs/vanus/internal/trigger/transform"
)

const (
Expand Down
8 changes: 5 additions & 3 deletions internal/store/segment/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/vanus-labs/vanus/observability/tracing"
"github.com/vanus-labs/vanus/pkg/cluster"
"github.com/vanus-labs/vanus/pkg/errors"
errinterceptor "github.com/vanus-labs/vanus/pkg/grpc/interceptor/errors"
"github.com/vanus-labs/vanus/pkg/util"
cepb "github.com/vanus-labs/vanus/proto/pkg/cloudevents"
ctrlpb "github.com/vanus-labs/vanus/proto/pkg/controller"
Expand All @@ -54,7 +55,6 @@ import (

// this project.
"github.com/vanus-labs/vanus/internal/primitive"
"github.com/vanus-labs/vanus/internal/primitive/interceptor/errinterceptor"
"github.com/vanus-labs/vanus/internal/primitive/vanus"
"github.com/vanus-labs/vanus/internal/store"
"github.com/vanus-labs/vanus/internal/store/block"
Expand Down Expand Up @@ -554,12 +554,14 @@ func (s *server) AppendToBlock(ctx context.Context, id vanus.ID, events []*cepb.
b.Append(ctx, entries, future.onAppended)
seqs, err := future.wait()
if err != nil {
metrics.WriteTPSCounterVec.WithLabelValues(s.volumeIDStr, b.IDStr(), metrics.LabelFailed).Add(float64(len(events)))
metrics.WriteTPSCounterVec.WithLabelValues(s.volumeIDStr, b.IDStr(),
metrics.LabelFailed).Add(float64(len(events)))
metrics.WriteThroughputCounterVec.WithLabelValues(s.volumeIDStr, b.IDStr(), metrics.LabelFailed).Add(float64(size))
return nil, s.processAppendError(ctx, b, err)
}
metrics.WriteTPSCounterVec.WithLabelValues(s.volumeIDStr, b.IDStr(), metrics.LabelSuccess).Add(float64(len(events)))
metrics.WriteThroughputCounterVec.WithLabelValues(s.volumeIDStr, b.IDStr(), metrics.LabelSuccess).Add(float64(size))
metrics.WriteThroughputCounterVec.WithLabelValues(s.volumeIDStr, b.IDStr(),
metrics.LabelSuccess).Add(float64(size))
return seqs, nil
}

Expand Down
9 changes: 7 additions & 2 deletions pkg/cluster/raw_client/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,29 @@
package raw_client

import (
// standard libraries.
"context"
"fmt"
"os"
"strconv"
"sync"
"time"

// third-party libraries.
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"

"github.com/vanus-labs/vanus/internal/primitive/interceptor/errinterceptor"
// first-party libraries.
"github.com/vanus-labs/vanus/observability/log"
"github.com/vanus-labs/vanus/pkg/errors"
ctrlpb "github.com/vanus-labs/vanus/proto/pkg/controller"

// this project.
"github.com/vanus-labs/vanus/pkg/errors"
errinterceptor "github.com/vanus-labs/vanus/pkg/grpc/interceptor/errors"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package errinterceptor
package errors

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package errinterceptor
package errors

0 comments on commit 1fe5c19

Please sign in to comment.