Compare commits

...

35 Commits
v4 ... v3

Author SHA1 Message Date
08389ffa3a update for latest micro
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-23 11:22:40 +03:00
08a832569a
Merge pull request #97 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.42
Bump go.unistack.org/micro/v3 from 3.10.40 to 3.10.42
2024-03-05 03:08:02 +03:00
dependabot[bot]
81c7d9cc9a
Bump go.unistack.org/micro/v3 from 3.10.40 to 3.10.42
Bumps go.unistack.org/micro/v3 from 3.10.40 to 3.10.42.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-05 00:06:12 +00:00
4ba456d7a7
Merge pull request #96 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.40
Bump go.unistack.org/micro/v3 from 3.10.39 to 3.10.40
2024-02-29 03:31:54 +03:00
dependabot[bot]
6f18745792
Bump go.unistack.org/micro/v3 from 3.10.39 to 3.10.40
Bumps go.unistack.org/micro/v3 from 3.10.39 to 3.10.40.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-29 00:29:58 +00:00
3e7795a981
Merge pull request #95 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.39
Bump go.unistack.org/micro/v3 from 3.10.38 to 3.10.39
2024-02-23 03:46:12 +03:00
dependabot[bot]
382cd1db32
Bump go.unistack.org/micro/v3 from 3.10.38 to 3.10.39
Bumps go.unistack.org/micro/v3 from 3.10.38 to 3.10.39.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-23 00:44:21 +00:00
129b680834
Merge pull request #93 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.38
Bump go.unistack.org/micro/v3 from 3.10.36 to 3.10.38
2024-02-09 03:49:01 +03:00
dependabot[bot]
62f3faecaa
Bump go.unistack.org/micro/v3 from 3.10.36 to 3.10.38
Bumps go.unistack.org/micro/v3 from 3.10.36 to 3.10.38.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-09 00:47:08 +00:00
b469fa26bd
Merge pull request #91 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.36
Bump go.unistack.org/micro/v3 from 3.10.35 to 3.10.36
2024-01-15 03:48:37 +03:00
dependabot[bot]
5127f912dc
Bump go.unistack.org/micro/v3 from 3.10.35 to 3.10.36
Bumps go.unistack.org/micro/v3 from 3.10.35 to 3.10.36.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-15 00:46:50 +00:00
eda442b1ab
Merge pull request #90 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.35
Bump go.unistack.org/micro/v3 from 3.10.32 to 3.10.35
2023-12-21 03:40:37 +03:00
dependabot[bot]
d5cc390c17
Bump go.unistack.org/micro/v3 from 3.10.32 to 3.10.35
Bumps go.unistack.org/micro/v3 from 3.10.32 to 3.10.35.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-21 00:38:44 +00:00
e348a6e9fb
Merge pull request #87 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.32
Bump go.unistack.org/micro/v3 from 3.10.31 to 3.10.32
2023-11-14 03:52:10 +03:00
dependabot[bot]
5d349e196d
Bump go.unistack.org/micro/v3 from 3.10.31 to 3.10.32
Bumps go.unistack.org/micro/v3 from 3.10.31 to 3.10.32.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-14 00:48:57 +00:00
80e8f68a9f
Merge pull request #86 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.31
Bump go.unistack.org/micro/v3 from 3.10.29 to 3.10.31
2023-11-02 03:31:53 +03:00
dependabot[bot]
9926bd992b
Bump go.unistack.org/micro/v3 from 3.10.29 to 3.10.31
Bumps go.unistack.org/micro/v3 from 3.10.29 to 3.10.31.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-02 00:29:16 +00:00
cbe4fb2f02
Merge pull request #85 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.29
Bump go.unistack.org/micro/v3 from 3.10.28 to 3.10.29
2023-10-26 03:40:29 +03:00
dependabot[bot]
9854bf456a
Bump go.unistack.org/micro/v3 from 3.10.28 to 3.10.29
Bumps go.unistack.org/micro/v3 from 3.10.28 to 3.10.29.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-26 00:37:07 +00:00
d40008c676
Merge pull request #84 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.28
Bump go.unistack.org/micro/v3 from 3.10.27 to 3.10.28
2023-09-11 03:05:06 +03:00
dependabot[bot]
da6221e3b7
Bump go.unistack.org/micro/v3 from 3.10.27 to 3.10.28
Bumps go.unistack.org/micro/v3 from 3.10.27 to 3.10.28.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-11 00:03:02 +00:00
ac4aab65fb
Merge pull request #82 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.27
Bump go.unistack.org/micro/v3 from 3.10.25 to 3.10.27
2023-09-04 03:42:36 +03:00
dependabot[bot]
65b5fd8342
Bump go.unistack.org/micro/v3 from 3.10.25 to 3.10.27
Bumps go.unistack.org/micro/v3 from 3.10.25 to 3.10.27.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-04 00:39:34 +00:00
763b119289
Merge pull request #80 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.25
Bump go.unistack.org/micro/v3 from 3.10.24 to 3.10.25
2023-08-08 03:36:36 +03:00
dependabot[bot]
619d4ebb99
Bump go.unistack.org/micro/v3 from 3.10.24 to 3.10.25
Bumps go.unistack.org/micro/v3 from 3.10.24 to 3.10.25.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-08 00:34:18 +00:00
39b8f0a01d
Merge pull request #79 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.24
Bump go.unistack.org/micro/v3 from 3.10.23 to 3.10.24
2023-07-14 03:43:48 +03:00
dependabot[bot]
ec40a36254
Bump go.unistack.org/micro/v3 from 3.10.23 to 3.10.24
Bumps go.unistack.org/micro/v3 from 3.10.23 to 3.10.24.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-14 00:42:22 +00:00
0fabb2c777
Merge pull request #78 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.23
Bump go.unistack.org/micro/v3 from 3.10.22 to 3.10.23
2023-07-04 03:25:27 +03:00
dependabot[bot]
39ed1ba5b2
Bump go.unistack.org/micro/v3 from 3.10.22 to 3.10.23
Bumps go.unistack.org/micro/v3 from 3.10.22 to 3.10.23.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-04 00:24:10 +00:00
5cb43f196b
Merge pull request #74 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.22
Bump go.unistack.org/micro/v3 from 3.10.21 to 3.10.22
2023-05-30 03:59:34 +03:00
dependabot[bot]
99b6a44134
Bump go.unistack.org/micro/v3 from 3.10.21 to 3.10.22
Bumps go.unistack.org/micro/v3 from 3.10.21 to 3.10.22.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-30 00:58:11 +00:00
ee5f59121b
Merge pull request #73 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.21
Bump go.unistack.org/micro/v3 from 3.10.20 to 3.10.21
2023-05-29 04:28:34 +03:00
dependabot[bot]
5ecfb46d14
Bump go.unistack.org/micro/v3 from 3.10.20 to 3.10.21
Bumps go.unistack.org/micro/v3 from 3.10.20 to 3.10.21.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-29 01:26:20 +00:00
9c76e6a498
Merge pull request #72 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.20
Bump go.unistack.org/micro/v3 from 3.10.19 to 3.10.20
2023-05-26 03:59:58 +03:00
dependabot[bot]
57a0f75e22
Bump go.unistack.org/micro/v3 from 3.10.19 to 3.10.20
Bumps go.unistack.org/micro/v3 from 3.10.19 to 3.10.20.

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-26 00:58:17 +00:00
3 changed files with 2609 additions and 93 deletions

7
go.mod
View File

@ -2,4 +2,9 @@ module go.unistack.org/micro-wrapper-recovery/v3
go 1.16
require go.unistack.org/micro/v3 v3.10.19
require (
go.unistack.org/micro/v3 v3.10.66
golang.org/x/sys v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect
google.golang.org/grpc v1.63.2 // indirect
)

2595
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
package recovery // import "go.unistack.org/micro-wrapper-recovery/v3"
package recovery
import (
"context"
@ -8,11 +8,6 @@ import (
"go.unistack.org/micro/v3/server"
)
var (
_ server.HandlerWrapper = NewServerHandlerWrapper()
_ server.SubscriberWrapper = NewServerSubscriberWrapper()
)
func NewOptions(opts ...Option) Options {
options := Options{
ServerHandlerFn: DefaultServerHandlerFn,
@ -31,13 +26,13 @@ type Options struct {
type Option func(*Options)
func ServerHandlerFn(fn func(context.Context, server.Request, interface{}, error) error) Option {
func ServerHandlerFunc(fn func(context.Context, server.Request, interface{}, error) error) Option {
return func(o *Options) {
o.ServerHandlerFn = fn
}
}
func ServerSubscriberFn(fn func(context.Context, server.Message, error) error) Option {
func ServerSubscriberFunc(fn func(context.Context, server.Message, error) error) Option {
return func(o *Options) {
o.ServerSubscriberFn = fn
}
@ -52,16 +47,17 @@ var (
}
)
type wrapper struct {
var Hook = NewHook()
type hook struct {
opts Options
}
func NewServerHandlerWrapper(opts ...Option) server.HandlerWrapper {
handler := &wrapper{opts: NewOptions(opts...)}
return handler.HandlerFunc
func NewHook(opts ...Option) *hook {
return &hook{opts: NewOptions(opts...)}
}
func (w *wrapper) HandlerFunc(fn server.HandlerFunc) server.HandlerFunc {
func (w *hook) ServerHandler(next server.FuncHandler) server.FuncHandler {
return func(ctx context.Context, req server.Request, rsp interface{}) (err error) {
defer func() {
r := recover()
@ -74,17 +70,12 @@ func (w *wrapper) HandlerFunc(fn server.HandlerFunc) server.HandlerFunc {
err = w.opts.ServerHandlerFn(ctx, req, rsp, fmt.Errorf("%v", r))
}
}()
err = fn(ctx, req, rsp)
err = next(ctx, req, rsp)
return err
}
}
func NewServerSubscriberWrapper(opts ...Option) server.SubscriberWrapper {
handler := &wrapper{opts: NewOptions(opts...)}
return handler.SubscriberFunc
}
func (w *wrapper) SubscriberFunc(fn server.SubscriberFunc) server.SubscriberFunc {
func (w *hook) ServerSubscriber(next server.FuncSubHandler) server.FuncSubHandler {
return func(ctx context.Context, msg server.Message) (err error) {
defer func() {
r := recover()
@ -97,74 +88,7 @@ func (w *wrapper) SubscriberFunc(fn server.SubscriberFunc) server.SubscriberFunc
err = w.opts.ServerSubscriberFn(ctx, msg, fmt.Errorf("%v", r))
}
}()
err = fn(ctx, msg)
err = next(ctx, msg)
return err
}
}
/*
func NewClientWrapper() client.Wrapper {
return func(c client.Client) client.Client {
handler := &wrapper{
clientClient: c,
}
return handler
}
}
func NewCallWrapper() client.CallWrapper {
return func(fn client.CallFunc) client.CallFunc {
handler := &wrapper{
clientCallFunc: fn,
}
return handler.CallFunc
}
}
func (w *wrapper) CallFunc(ctx context.Context, addr string, req client.Request, rsp interface{}, opts client.CallOptions) (err error) {
defer func() {
r := recover()
switch verr := r.(type) {
case nil:
return
case error:
err = w.clientCallFunc(ctx, addr, req, rsp, opts, verr)
default:
err = w.clientCallFunc(ctx, addr, req, rsp, opts, fmt.Errorf("%v", r))
}
}()
err = w.CallFunc(ctx, addr, req, rsp, opts)
return err
}
func (w *wrapper) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error {
defer func() {
r := recover()
switch verr := r.(type) {
case nil:
return
case error:
err = w.clientClient.Call(ctx, addr, req, rsp, opts, verr)
default:
err = w.clientClient.Call(ctx, addr, req, rsp, opts, fmt.Errorf("%v", r))
}
}()
err = w.clientClient.Call(ctx, req, rsp, opts...)
return err
}
func (w *wrapper) Stream(ctx context.Context, req client.Request, opts ...client.CallOption) (client.Stream, error) {
stream, err := w.Client.Stream(ctx, req, opts...)
return stream, err
}
func (w *wrapper) Publish(ctx context.Context, p client.Message, opts ...client.PublishOption) error {
err := w.Client.Publish(ctx, p, opts...)
return err
}
*/