Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable internal parameters (e.g., parallelization) #2

Open
kevinmichaelchen opened this issue Jun 9, 2022 · 0 comments
Open

Comments

@kevinmichaelchen
Copy link
Member

kevinmichaelchen commented Jun 9, 2022

We can allow consumers of this library to configure certain parameters, such as parallelization factors, using the Functional Options pattern:

type config struct {
	parallelization int
}

func newConfig() config {
	return config{
		parallelization: 10,
	}
}

type BetweenOption func(*config)

// WithParallelization configures the level of parallelization to use for
// concurrent Distance Matrix API requests.
func WithParallelization(parallelization int) BetweenOption {
	return func(c *config) {
		c.parallelization = parallelization
	}
}

func BetweenPoints(
	ctx context.Context,
	client *maps.Client,
	in distance.BetweenPointsInput,
	options ...BetweenOption,
) (*distance.MatrixResponse, error) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant