service.go
func NewService(config ServiceConfig) (Service, error) {
	// Dependencies.
	if config.BackoffFactory == nil {
		return nil, maskAnyf(invalidConfigError, "backoff factory must not be empty")
	}
	if config.RandFactory == nil {
		return nil, maskAnyf(invalidConfigError, "rand factory must not be empty")
	}

	// Settings.
	if config.RandReader == nil {
		return nil, maskAnyf(invalidConfigError, "rand reader must not be empty")
	}

	newService := &service{
		// Dependencies.
		backoffFactory: config.BackoffFactory,
		randFactory:    config.RandFactory,

		// Settings.
		randReader: config.RandReader,
		timeout:    config.Timeout,
	}

	return newService, nil
}
func NewService(config ServiceConfig) (Service, error) {
	// Dependencies.
	if config.BackoffFactory == nil {
		return nil, maskAnyf(invalidConfigError, "backoff factory must not be empty")
	}
	if config.RandFactory == nil {
		return nil, maskAnyf(invalidConfigError, "rand factory must not be empty")
	}

	// Settings.
	if config.RandReader == nil {
		return nil, maskAnyf(invalidConfigError, "rand reader must not be empty")
	}

	newService := &service{
		// Dependencies.
		backoffFactory: config.BackoffFactory,
		randFactory:    config.RandFactory,

		// Settings.
		randReader: config.RandReader,
		timeout:    config.Timeout,
	}

	return newService, nil
}
// NewService creates a new configured random service.