Skip to content

Possible easier to use top-level API #37

@bassosimone

Description

@bassosimone

It seems the current API based on channels is not very comfortable to use. A better design would probably be to expose a blocking API with a callback, for example:

func (c *Client) Run(ctx context.Context, fn func(m *spec.Measurement)) (summary Summary, err error) {
  var ch chan spec.Measurement
  ch, err = c.StartDownload(ctx)
  if err != nil {
    return
  }
  for m := range ch {
    // TODO: fill the summary
    fn(m)
  }
  ch, err = c.StartUpload(ctx)
  if err != nil {
    return
  }
  for m := range ch {
    // TODO: fill the summary
    fn(m)
  }
  return
}

This may or may not be combined with a summary. Note that this API does not cause data races because the callback is called in the same thread context of the blocking Run call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions