@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user