Skip to content
Snippets Groups Projects
Commit c9fd28d7 authored by Anton Sattarov's avatar Anton Sattarov :cucumber:
Browse files

gen middlewares

parent 10d4be8a
No related branches found
No related tags found
No related merge requests found
......@@ -40,3 +40,7 @@ func (m *encodeDecodeMiddleware) Get(ctx context.Context, spaceId, envId string,
}
return
}
func (m *encodeDecodeMiddleware) Publish(ctx context.Context, spaceId string, envId string, references []*references.Reference, recursive bool, force bool) (published []*references.Reference, notfound []*references.Reference, unpublished []*references.Reference, err error) {
return m.next.Publish(ctx, spaceId, envId, references, recursive, force)
}
package middleware
// Code generated by gowrap. DO NOT EDIT.
// template: ../../../assets/templates/middleware/error_log
// gowrap: http://github.com/hexdigest/gowrap
// DO NOT EDIT!
// This code is generated with http://github.com/hexdigest/gowrap tool
// using ../../../assets/templates/middleware/error_log template
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/error_log -o error_logging_middleware.go -l ""
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/error_log -o error_logging_middleware.go
import (
"context"
......@@ -39,3 +39,13 @@ func (m *errorLoggingMiddleware) Get(ctx context.Context, spaceId string, envId
}()
return m.next.Get(ctx, spaceId, envId, references)
}
func (m *errorLoggingMiddleware) Publish(ctx context.Context, spaceId string, envId string, references []*references.Reference, recursive bool, force bool) (published []*references.Reference, notfound []*references.Reference, unpublished []*references.Reference, err error) {
logger := m.logger
defer func() {
if err != nil {
logger.Warn("response error", zap.Error(err))
}
}()
return m.next.Publish(ctx, spaceId, envId, references, recursive, force)
}
package middleware
// Code generated by gowrap. DO NOT EDIT.
// template: ../../../assets/templates/middleware/access_log
// gowrap: http://github.com/hexdigest/gowrap
// DO NOT EDIT!
// This code is generated with http://github.com/hexdigest/gowrap tool
// using ../../../assets/templates/middleware/access_log template
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/access_log -o logging_middleware.go -l ""
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/access_log -o logging_middleware.go
import (
"context"
......@@ -73,3 +73,46 @@ func (m *loggingMiddleware) Get(ctx context.Context, spaceId string, envId strin
return items, notfound, err
}
func (m *loggingMiddleware) Publish(ctx context.Context, spaceId string, envId string, references []*references.Reference, recursive bool, force bool) (published []*references.Reference, notfound []*references.Reference, unpublished []*references.Reference, err error) {
begin := time.Now()
var fields []zapcore.Field
for k, v := range map[string]interface{}{
"ctx": ctx,
"spaceId": spaceId,
"envId": envId,
"references": references,
"recursive": recursive,
"force": force} {
if k == "ctx" {
fields = append(fields, zap.String("principal", fmt.Sprint(auth.GetPrincipal(ctx))))
continue
}
fields = append(fields, zap.Reflect(k, v))
}
m.logger.Debug("Publish.Request", fields...)
published, notfound, unpublished, err = m.next.Publish(ctx, spaceId, envId, references, recursive, force)
fields = []zapcore.Field{
zap.Duration("time", time.Since(begin)),
}
for k, v := range map[string]interface{}{
"published": published,
"notfound": notfound,
"unpublished": unpublished,
"err": err} {
if k == "err" {
err, _ := v.(error)
fields = append(fields, zap.Error(err))
continue
}
fields = append(fields, zap.Reflect(k, v))
}
m.logger.Debug("Publish.Response", fields...)
return published, notfound, unpublished, err
}
// Code generated by gowrap. DO NOT EDIT.
// template: ../../../assets/templates/middleware/middleware
// gowrap: http://github.com/hexdigest/gowrap
package middleware
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/middleware -o middleware.go -l ""
// DO NOT EDIT!
// This code is generated with http://github.com/hexdigest/gowrap tool
// using ../../../assets/templates/middleware/middleware template
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/middleware -o middleware.go
import (
"git.perx.ru/perxis/perxis-go/pkg/references"
......
// Code generated by gowrap. DO NOT EDIT.
// template: ../../../assets/templates/middleware/recovery
// gowrap: http://github.com/hexdigest/gowrap
package middleware
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/recovery -o recovering_middleware.go -l ""
// DO NOT EDIT!
// This code is generated with http://github.com/hexdigest/gowrap tool
// using ../../../assets/templates/middleware/recovery template
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/recovery -o recovering_middleware.go
import (
"context"
......@@ -42,3 +42,15 @@ func (m *recoveringMiddleware) Get(ctx context.Context, spaceId string, envId st
return m.next.Get(ctx, spaceId, envId, references)
}
func (m *recoveringMiddleware) Publish(ctx context.Context, spaceId string, envId string, references []*references.Reference, recursive bool, force bool) (published []*references.Reference, notfound []*references.Reference, unpublished []*references.Reference, err error) {
logger := m.logger
defer func() {
if r := recover(); r != nil {
logger.Error("panic", zap.Error(fmt.Errorf("%v", r)))
err = fmt.Errorf("%v", r)
}
}()
return m.next.Publish(ctx, spaceId, envId, references, recursive, force)
}
......@@ -11,4 +11,6 @@ import (
// @grpc-addr content.references.References
type References interface {
Get(ctx context.Context, spaceId, envId string, references []*Reference) (items []*items.Item, notfound []*Reference, err error)
Publish(ctx context.Context, spaceId, envId string, references []*Reference, recursive, force bool) (published []*Reference, notfound []*Reference, unpublished []*Reference, err error)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment