rename fields
This commit is contained in:
@@ -24,26 +24,26 @@ import (
|
||||
)
|
||||
|
||||
type Client interface {
|
||||
Run(ctx context.Context, st storage.Storage) chan *pb.AddPackageRsp
|
||||
Run(ctx context.Context, st storage.Storage) chan *pb.AddPackageReq
|
||||
IsClose() bool
|
||||
Done() <-chan struct{}
|
||||
}
|
||||
|
||||
type client struct {
|
||||
worker chan *pb.AddPackageRsp
|
||||
worker chan *pb.AddPackageReq
|
||||
closed bool
|
||||
lock chan struct{}
|
||||
}
|
||||
|
||||
func NewClient(cap uint) Client {
|
||||
return &client{
|
||||
make(chan *pb.AddPackageRsp, cap),
|
||||
make(chan *pb.AddPackageReq, cap),
|
||||
false,
|
||||
make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *client) Run(ctx context.Context, st storage.Storage) chan *pb.AddPackageRsp {
|
||||
func (c *client) Run(ctx context.Context, st storage.Storage) chan *pb.AddPackageReq {
|
||||
go func() {
|
||||
defer close(c.worker)
|
||||
for {
|
||||
@@ -71,8 +71,8 @@ func (c *client) Done() <-chan struct{} {
|
||||
return c.lock
|
||||
}
|
||||
|
||||
func runner(ctx context.Context, st storage.Storage, rsp *pb.AddPackageRsp) {
|
||||
modules, err := getGoModule(ctx, rsp.Url.Value)
|
||||
func runner(ctx context.Context, st storage.Storage, req *pb.AddPackageReq) {
|
||||
modules, err := getGoModule(ctx, req.Url.Value)
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
return
|
||||
@@ -80,12 +80,12 @@ func runner(ctx context.Context, st storage.Storage, rsp *pb.AddPackageRsp) {
|
||||
|
||||
logger.Infof(ctx, "success get list mod", modules)
|
||||
|
||||
if rsp.Modules, err = st.InsertButchModules(ctx, modules); err != nil {
|
||||
if req.Modules, err = st.InsertButchModules(ctx, modules); err != nil {
|
||||
logger.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err = st.AddPackage(ctx, rsp); err != nil {
|
||||
if err = st.AddPackage(ctx, req); err != nil {
|
||||
logger.Error(ctx, err)
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ func TestClientPG(t *testing.T) {
|
||||
|
||||
ch := cli.Run(ctx, s)
|
||||
|
||||
data := &pb.AddPackageRsp{
|
||||
data := &pb.AddPackageReq{
|
||||
Name: wrapperspb.String("test"),
|
||||
Url: wrapperspb.String("https://github.com/dantedenis/service_history.git"),
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func TestClientLite(t *testing.T) {
|
||||
|
||||
ch := cli.Run(ctx, s)
|
||||
|
||||
data := &pb.AddPackageRsp{
|
||||
data := &pb.AddPackageReq{
|
||||
Name: wrapperspb.String("test"),
|
||||
Url: wrapperspb.String("https://github.com/dantedenis/service_history.git"),
|
||||
}
|
||||
|
@@ -132,6 +132,7 @@ func NewService(ctx context.Context) (micro.Service, error) {
|
||||
mux.HandleFunc("/updatePackage", handler.Methods(http.MethodPost, h.UpdatePackage))
|
||||
mux.HandleFunc("/addComment", handler.Methods(http.MethodPut, h.AddComment))
|
||||
mux.HandleFunc("/addPackage", handler.Methods(http.MethodPost, h.AddPackage))
|
||||
mux.HandleFunc("/getModule", handler.Methods(http.MethodGet, h.GetModule))
|
||||
|
||||
if err = svc.Server().Handle(svc.Server().NewHandler(mux)); err != nil {
|
||||
logger.Fatalf(ctx, "failed to register handler: %v", err)
|
||||
|
Reference in New Issue
Block a user