rename fields

This commit is contained in:
2023-08-11 08:58:31 +03:00
parent 1eeb6607be
commit c1f1e31569
13 changed files with 1090 additions and 680 deletions

View File

@@ -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)
}
}

View File

@@ -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"),
}