feat: implemented service/transport/main layers
This commit is contained in:
parent
5158c5d7c9
commit
bcb9ace54c
29 changed files with 804 additions and 393 deletions
7
internal/pkg/ds/predictor.go
Normal file
7
internal/pkg/ds/predictor.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package ds
|
||||
|
||||
type PredictionParameters struct {
|
||||
}
|
||||
|
||||
type PredicitonResult struct {
|
||||
}
|
||||
25
internal/pkg/errcodes/errcodes.go
Normal file
25
internal/pkg/errcodes/errcodes.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package errcodes
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ErrorCode struct {
|
||||
StatusCode int
|
||||
Message string
|
||||
Details string
|
||||
}
|
||||
|
||||
var errorCodeCounter int32
|
||||
|
||||
func New(statusCode int, message string, details ...string) *ErrorCode {
|
||||
return &ErrorCode{
|
||||
StatusCode: statusCode,
|
||||
Message: message,
|
||||
Details: strings.Join(details, " "),
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ErrorCode) Error() string {
|
||||
return e.Message
|
||||
}
|
||||
23
internal/pkg/log/log.go
Normal file
23
internal/pkg/log/log.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package log
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type ctxLogKey struct{}
|
||||
|
||||
func ToCtx(ctx context.Context, lg *zap.Logger) context.Context {
|
||||
return context.WithValue(ctx, ctxLogKey{}, lg)
|
||||
}
|
||||
|
||||
func Ctx(ctx context.Context) *zap.Logger {
|
||||
lg, ok := ctx.Value(ctxLogKey{}).(*zap.Logger)
|
||||
if !ok || lg == nil {
|
||||
zap.L().Error("no logger in context, using global")
|
||||
return zap.L()
|
||||
}
|
||||
|
||||
return lg
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue