Skip to content

Commit

Permalink
Rename Ls to GoLs and Ls2 to Ls
Browse files Browse the repository at this point in the history
  • Loading branch information
gammazero committed Dec 3, 2024
1 parent f06377d commit da800d8
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pinning/remote/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (pinLsOpts) LsMeta(meta map[string]string) LsOption {

type pinResults = openapi.PinResults

// Ls2 writes pin statuses to the PinStatusGetter channel. The channel is
// Ls writes pin statuses to the PinStatusGetter channel. The channel is
// closed when there are no more pins. If an error occurs or ctx is canceled,
// then the channel is closed and an error is returned.
//
Expand All @@ -146,13 +146,13 @@ type pinResults = openapi.PinResults
// res := make(chan PinStatusGetter, 1)
// lsErr := make(chan error, 1)
// go func() {
// lsErr <- c.Ls2(ctx, res, opts...)
// lsErr <- c.Ls(ctx, res, opts...)
// }()
// for r := range res {
// processPin(r)
// }
// return <-lsErr
func (c *Client) Ls2(ctx context.Context, res chan<- PinStatusGetter, opts ...LsOption) (err error) {
func (c *Client) Ls(ctx context.Context, res chan<- PinStatusGetter, opts ...LsOption) (err error) {

Check warning on line 155 in pinning/remote/client/client.go

View check run for this annotation

Codecov / codecov/patch

pinning/remote/client/client.go#L155

Added line #L155 was not covered by tests
settings := new(lsSettings)
for _, o := range opts {
if err = o(settings); err != nil {

Check warning on line 158 in pinning/remote/client/client.go

View check run for this annotation

Codecov / codecov/patch

pinning/remote/client/client.go#L158

Added line #L158 was not covered by tests
Expand Down Expand Up @@ -208,19 +208,21 @@ func (c *Client) Ls2(ctx context.Context, res chan<- PinStatusGetter, opts ...Ls
return nil

Check warning on line 208 in pinning/remote/client/client.go

View check run for this annotation

Codecov / codecov/patch

pinning/remote/client/client.go#L208

Added line #L208 was not covered by tests
}

func (c *Client) Ls(ctx context.Context, opts ...LsOption) (<-chan PinStatusGetter, <-chan error) {
res := make(chan PinStatusGetter, 1)
// GoLs creates the results and error channels, starts the goroutine that calls
// Ls, and returns the channels to the caller.
func (c *Client) GoLs(ctx context.Context, opts ...LsOption) (<-chan PinStatusGetter, <-chan error) {
res := make(chan PinStatusGetter)
errs := make(chan error, 1)

go func() {
errs <- c.Ls2(ctx, res, opts...)
errs <- c.Ls(ctx, res, opts...)

Check warning on line 218 in pinning/remote/client/client.go

View check run for this annotation

Codecov / codecov/patch

pinning/remote/client/client.go#L213-L218

Added lines #L213 - L218 were not covered by tests
}()

return res, errs
}

func (c *Client) LsSync(ctx context.Context, opts ...LsOption) ([]PinStatusGetter, error) {
resCh, errCh := c.Ls(ctx, opts...)
resCh, errCh := c.GoLs(ctx, opts...)

Check warning on line 225 in pinning/remote/client/client.go

View check run for this annotation

Codecov / codecov/patch

pinning/remote/client/client.go#L225

Added line #L225 was not covered by tests

var res []PinStatusGetter
for r := range resCh {
Expand Down

0 comments on commit da800d8

Please sign in to comment.