Skip to content

Commit

Permalink
feat: aligned and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sujit-baniya committed Mar 2, 2024
1 parent 37b6254 commit 288b4ca
Show file tree
Hide file tree
Showing 31 changed files with 271 additions and 736 deletions.
4 changes: 2 additions & 2 deletions client/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
)

type TargetInfo struct {
Host string
Tags map[string]string
Host string
}

type Resolver interface {
Expand Down Expand Up @@ -76,8 +76,8 @@ type Instance interface {

type instance struct {
addr net.Addr
weight int
tags map[string]string
weight int
}

func (i *instance) Address() net.Addr {
Expand Down
6 changes: 3 additions & 3 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ replace github.com/oarkflow/frame => ../

require (
github.com/oarkflow/frame v0.0.60
github.com/oarkflow/log v1.0.74
github.com/oarkflow/pkg v0.1.22
go.opentelemetry.io/otel v1.23.1
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.23.1
Expand All @@ -20,12 +19,13 @@ require (
github.com/bytedance/go-tagexpr/v2 v2.9.11 // indirect
github.com/bytedance/gopkg v0.0.0-20240202110943-5e26950c5e57 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cloudwego/netpoll v0.5.2-0.20240206071512-faa52638971c // indirect
github.com/cloudwego/netpoll v0.5.2-0.20240220090456-7ba622bf763b // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
github.com/nyaruka/phonenumbers v1.0.55 // indirect
github.com/nyaruka/phonenumbers v1.3.2 // indirect
github.com/oarkflow/log v1.0.74 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
github.com/tidwall/match v1.1.1 // indirect
Expand Down
7 changes: 4 additions & 3 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ github.com/bytedance/gopkg v0.0.0-20240202110943-5e26950c5e57 h1:lXHfN6aablmJUX7
github.com/bytedance/gopkg v0.0.0-20240202110943-5e26950c5e57/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvDW77fgUQ=
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/cloudwego/netpoll v0.5.2-0.20240206071512-faa52638971c h1:7ChZnS1EkI2CGFJEL9/wAIhCgyWB+swQXxPrgGRpzy0=
github.com/cloudwego/netpoll v0.5.2-0.20240206071512-faa52638971c/go.mod h1:xVefXptcyheopwNDZjDPcfU6kIjZXZ4nY550k1yH9eQ=
github.com/cloudwego/netpoll v0.5.2-0.20240220090456-7ba622bf763b h1:ZHtA1Q20H9WoLPfMHCSkMv8wUrN7YENJfQCVybErGy8=
github.com/cloudwego/netpoll v0.5.2-0.20240220090456-7ba622bf763b/go.mod h1:xVefXptcyheopwNDZjDPcfU6kIjZXZ4nY550k1yH9eQ=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -28,8 +28,9 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 h1:Wqo399gCIufwto+VfwCSvsnfGpF/w5E9CNxSwbpD6No=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0/go.mod h1:qmOFXW2epJhM0qSnUUYpldc7gVz2KMQwJ/QYCDIa7XU=
github.com/nyaruka/phonenumbers v1.0.55 h1:bj0nTO88Y68KeUQ/n3Lo2KgK7lM1hF7L9NFuwcCl3yg=
github.com/nyaruka/phonenumbers v1.0.55/go.mod h1:sDaTZ/KPX5f8qyV9qN+hIm+4ZBARJrupC6LuhshJq1U=
github.com/nyaruka/phonenumbers v1.3.2 h1:ACdPdlDGabEwkF6Asfd1Jv+azcoPJP/FujXnnisp0vw=
github.com/nyaruka/phonenumbers v1.3.2/go.mod h1:4jyKp/BFUokLbCHyoZag+T3S1KezFVoEKtgnbpzItC4=
github.com/oarkflow/log v1.0.74 h1:ZF+G7ZMO2bHRcNMVovqa3LwkzxsaQqhaFCe92Gwwhtg=
github.com/oarkflow/log v1.0.74/go.mod h1:GjB0Np5m9DXTwlS2fpkH5jDsiTMYhD60aG/9UegLNvw=
github.com/oarkflow/pkg v0.1.22 h1:jlpBm4b1fuQkgDJEoozk28HkLZpx6qeTPCcU1AApRaQ=
Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require (
github.com/bytedance/go-tagexpr/v2 v2.9.11
github.com/bytedance/gopkg v0.0.0-20240202110943-5e26950c5e57
github.com/c9s/goprocinfo v0.0.0-20210130143923-c95fcf8c64a8
github.com/cloudwego/netpoll v0.5.2-0.20240206071512-faa52638971c
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/cloudwego/netpoll v0.5.2-0.20240220090456-7ba622bf763b
github.com/golang-jwt/jwt/v5 v5.2.0
github.com/oarkflow/log v1.0.74
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee
github.com/shirou/gopsutil/v3 v3.24.1
Expand All @@ -23,9 +23,8 @@ require (
github.com/andeya/ameda v1.5.3 // indirect
github.com/andeya/goutil v1.0.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/golang/protobuf v1.5.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/nyaruka/phonenumbers v1.0.55 // indirect
github.com/nyaruka/phonenumbers v1.3.2 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
Expand Down
17 changes: 6 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,23 @@ github.com/bytedance/gopkg v0.0.0-20240202110943-5e26950c5e57 h1:lXHfN6aablmJUX7
github.com/bytedance/gopkg v0.0.0-20240202110943-5e26950c5e57/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvDW77fgUQ=
github.com/c9s/goprocinfo v0.0.0-20210130143923-c95fcf8c64a8 h1:SjZ2GvvOononHOpK84APFuMvxqsk3tEIaKH/z4Rpu3g=
github.com/c9s/goprocinfo v0.0.0-20210130143923-c95fcf8c64a8/go.mod h1:uEyr4WpAH4hio6LFriaPkL938XnrvLpNPmQHBdrmbIE=
github.com/cloudwego/netpoll v0.5.2-0.20240206071512-faa52638971c h1:7ChZnS1EkI2CGFJEL9/wAIhCgyWB+swQXxPrgGRpzy0=
github.com/cloudwego/netpoll v0.5.2-0.20240206071512-faa52638971c/go.mod h1:xVefXptcyheopwNDZjDPcfU6kIjZXZ4nY550k1yH9eQ=
github.com/cloudwego/netpoll v0.5.2-0.20240220090456-7ba622bf763b h1:ZHtA1Q20H9WoLPfMHCSkMv8wUrN7YENJfQCVybErGy8=
github.com/cloudwego/netpoll v0.5.2-0.20240220090456-7ba622bf763b/go.mod h1:xVefXptcyheopwNDZjDPcfU6kIjZXZ4nY550k1yH9eQ=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw=
github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/nyaruka/phonenumbers v1.0.55 h1:bj0nTO88Y68KeUQ/n3Lo2KgK7lM1hF7L9NFuwcCl3yg=
github.com/nyaruka/phonenumbers v1.0.55/go.mod h1:sDaTZ/KPX5f8qyV9qN+hIm+4ZBARJrupC6LuhshJq1U=
github.com/nyaruka/phonenumbers v1.3.2 h1:ACdPdlDGabEwkF6Asfd1Jv+azcoPJP/FujXnnisp0vw=
github.com/nyaruka/phonenumbers v1.3.2/go.mod h1:4jyKp/BFUokLbCHyoZag+T3S1KezFVoEKtgnbpzItC4=
github.com/oarkflow/log v1.0.74 h1:ZF+G7ZMO2bHRcNMVovqa3LwkzxsaQqhaFCe92Gwwhtg=
github.com/oarkflow/log v1.0.74/go.mod h1:GjB0Np5m9DXTwlS2fpkH5jDsiTMYhD60aG/9UegLNvw=
github.com/philhofer/fwd v1.1.2 h1:bnDivRJ1EWPjUIRXV5KfORO897HTbpFAQddBdE8t7Gw=
Expand Down Expand Up @@ -91,7 +87,6 @@ golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
41 changes: 5 additions & 36 deletions middlewares/server/csrf/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,43 +66,12 @@ type CsrfExtractorHandler func(ctx context.Context, c *frame.Context) (string, e

// Options defines the config for middleware.
type Options struct {
// Secret used to generate token.
//
// Default: csrfSecret
Secret string

// Ignored methods will be considered no protection required.
//
// Optional. Default: "GET", "HEAD", "OPTIONS", "TRACE"
Next CsrfNextHandler
ErrorFunc frame.HandlerFunc
Extractor CsrfExtractorHandler
Secret string
KeyLookup string
IgnoreMethods []string

// Next defines a function to skip this middleware when returned true.
//
// Optional. Default: nil
Next CsrfNextHandler

// KeyLookup is a string in the form of "<source>:<key>" that is used
// to create an Extractor that extracts the token from the request.
// Possible values:
// - "header:<name>"
// - "query:<name>"
// - "param:<name>"
// - "form:<name>"
//
// Optional. Default: "header:X-CSRF-TOKEN"
KeyLookup string

// ErrorFunc is executed when an error is returned from frame.HandlerFunc.
//
// Optional. Default: func(context context.Context, c *frame.Context) { panic(c.Errors.Last()) }
ErrorFunc frame.HandlerFunc

// Extractor returns the csrf token.
//
// If set this will be used in place of an Extractor based on KeyLookup.
//
// Optional. Default will create an Extractor based on KeyLookup.
Extractor CsrfExtractorHandler
}

func (o *Options) Apply(opts []Option) {
Expand Down
14 changes: 1 addition & 13 deletions middlewares/server/etag/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,8 @@ import "github.com/oarkflow/frame"

// Config defines the config for middleware.
type Config struct {
// Weak indicates that a weak validator is used. Weak etags are easy
// to generate, but are far less useful for comparisons. Strong
// validators are ideal for comparisons but can be very difficult
// to generate efficiently. Weak ETag values of two representations
// of the same resources might be semantically equivalent, but not
// byte-for-byte identical. This means weak etags prevent caching
// when byte range requests are used, but strong etags mean range
// requests can still be cached.
Weak bool

// Next defines a function to skip this middleware when returned true.
//
// Optional. Default: nil
Next func(c *frame.Context) bool
Weak bool
}

// ConfigDefault is the default config
Expand Down
2 changes: 1 addition & 1 deletion middlewares/server/gzip/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ var (
type (
Options struct {
ExcludedExtensions ExcludedExtensions
DecompressFn frame.HandlerFunc
ExcludedPaths ExcludedPaths
ExcludedPathRegexes ExcludedPathRegexes
DecompressFn frame.HandlerFunc
}
Option func(*Options)
ExcludedExtensions map[string]bool
Expand Down
3 changes: 1 addition & 2 deletions middlewares/server/idempotency/locker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ type Locker interface {
}

type MemoryLock struct {
mu sync.Mutex

keys map[string]*sync.Mutex
mu sync.Mutex
}

func (l *MemoryLock) Lock(key string) error {
Expand Down
8 changes: 3 additions & 5 deletions middlewares/server/idempotency/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package idempotency

//go:generate msgp -o=response_msgp.go -io=false -unexported
type response struct {
StatusCode int `msg:"sc"`

Headers map[string][]string `msg:"hs"`

Body []byte `msg:"b"`
Headers map[string][]string `msg:"hs"`
Body []byte `msg:"b"`
StatusCode int `msg:"sc"`
}
Loading

0 comments on commit 288b4ca

Please sign in to comment.