use worker

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2023-08-18 23:59:15 +03:00
parent 78f0ae14d7
commit 0e18a63f10
46 changed files with 2195 additions and 1181 deletions

View File

@@ -1,27 +1,19 @@
package handler
import (
"context"
"errors"
"net/http"
"strconv"
"github.com/google/uuid"
"go.unistack.org/micro/v4"
cligit "git.unistack.org/unistack-org/pkgdash/internal/service/client_git"
"git.unistack.org/unistack-org/pkgdash/internal/storage"
pb "git.unistack.org/unistack-org/pkgdash/proto"
"google.golang.org/protobuf/encoding/protojson"
"github.com/google/uuid"
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v4"
"go.unistack.org/micro/v4/codec"
)
type Handler struct {
svc micro.Service
store storage.Storage
protojson.MarshalOptions
protojson.UnmarshalOptions
git cligit.Client
store storage.Storage
codec codec.Codec
chanUrl chan *pb.PackagesCreateReq
}
@@ -52,25 +44,11 @@ func NewValidationError(err error) *pb.ErrorRsp {
}
}
func NewHandler(svc micro.Service, client cligit.Client) *Handler {
func NewHandler(store storage.Storage) (*Handler, error) {
h := &Handler{
svc: svc,
git: client,
}
h.EmitUnpopulated = true
h.UseProtoNames = false
return h
}
func (h *Handler) Init(ctx context.Context) error {
store, err := storage.FromContext(h.svc.Options().Context)
if err != nil {
return errors.New("missing storage")
codec: jsonpbcodec.NewCodec(),
store: store,
}
h.chanUrl = h.git.Run(ctx, store)
h.store = store
return nil
return h, nil
}