Skip to content

Commit

Permalink
Add pointer related code
Browse files Browse the repository at this point in the history
  • Loading branch information
dongxuny committed Dec 24, 2022
1 parent 144a082 commit de36d87
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/gogf/gf/v2 v2.2.1
github.com/golang-jwt/jwt/v4 v4.4.2
github.com/prometheus/client_golang v1.13.0
github.com/rookie-ninja/rk-entry/v2 v2.2.14
github.com/rookie-ninja/rk-entry/v2 v2.2.15
github.com/rookie-ninja/rk-logger v1.2.13
github.com/rookie-ninja/rk-query v1.2.14
github.com/stretchr/testify v1.8.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqn
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/rookie-ninja/rk-entry/v2 v2.2.14 h1:PHzofuw52zfskrgJKC+WIMt1LtoBosrukjWHZ/DKsTE=
github.com/rookie-ninja/rk-entry/v2 v2.2.14/go.mod h1:P/Fd6Oyvvx0ITbEU2lzO3KkQ9miWVwd84aPaC0LMD0o=
github.com/rookie-ninja/rk-entry/v2 v2.2.15 h1:K5Ww1wCjOcAvK11pBA8qM7FpbHyFE5i+YQBAIYxPrZc=
github.com/rookie-ninja/rk-entry/v2 v2.2.15/go.mod h1:P/Fd6Oyvvx0ITbEU2lzO3KkQ9miWVwd84aPaC0LMD0o=
github.com/rookie-ninja/rk-logger v1.2.13 h1:ERxeNZUmszlY4xehHcJRXECPtbjYIXzN8yRIyYyLGsg=
github.com/rookie-ninja/rk-logger v1.2.13/go.mod h1:0ZiGn1KsHKOmCv+FHMH7k40DWYSJcj5yIR3EYcjlnLs=
github.com/rookie-ninja/rk-query v1.2.14 h1:aYNyMXixpsEYRfEOz9Npt5QG3A6BQlo9vKjYc78x7bc=
Expand Down
14 changes: 13 additions & 1 deletion middleware/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
var (
noopTracerProvider = trace.NewNoopTracerProvider()
noopEvent = rkquery.NewEventFactory().CreateEventNoop()
pointerCreator rkcursor.PointerCreator
)

// GetIncomingHeaders extract call-scoped incoming headers
Expand Down Expand Up @@ -59,12 +60,23 @@ func SetHeaderToClient(ctx *ghttp.Request, key, value string) {
header.Set(key, value)
}

// SetPointerCreator override rkcursor.PointerCreator
func SetPointerCreator(creator rkcursor.PointerCreator) {
pointerCreator = creator
}

// GetCursor create rkcursor.Cursor instance
func GetCursor(ctx *ghttp.Request) *rkcursor.Cursor {
return rkcursor.NewCursor(
res := rkcursor.NewCursor(
rkcursor.WithLogger(GetLogger(ctx)),
rkcursor.WithEvent(GetEvent(ctx)),
rkcursor.WithEntryNameAndType(GetEntryName(ctx), "GoFrameEntry"))

if pointerCreator != nil {
res.Creator = pointerCreator
}

return res
}

// GetEvent extract takes the call-scoped EventData from middleware.
Expand Down

0 comments on commit de36d87

Please sign in to comment.