Conversation
|
That's a good question; given we're on track to convert all endpoints to builders, it might make sense for the client to follow a similar pattern. I was hoping that once we have the endpoints in place, we could take a look at the client builders after. But it seems I wasn't the only one thinking of that (: What is a pipeline? 1A "pipeline" in our SDK is an HTTP backend + corresponding middleware 2. It's defined as follows: #[derive(Debug, Clone)]
pub struct Pipeline {
http_client: Arc<dyn HttpClient>,
pipeline: Vec<Arc<dyn Policy>>,
}
What would usage of our clients look like with this PR?Policies on the pipeline currently cannot be modified or extended, which is what the PR under discussion attempts to address. Taking let account = std::env::var("COSMOS_ACCOUNT").unwrap();
let master_key = std::env::var("COSMOS_MASTER_KEY").unwrap();
let auth = AuthorizationToken::primary_from_base64(&master_key)?;
// Create a new Cosmos client with a custom policy
let options = CosmosOptions::default();
let mut pipeline = Pipeline::new(
option_env!("CARGO_PKG_NAME"),
option_env!("CARGO_PKG_VERSION"),
ClientOptions::default(),
vec![], // per-call policies
vec![Arc::new(ExamplePolicy::new())], // per-retry policies
);
let client = CosmosClient::new(account, auth, options, pipeline);This PR moves the construction of An alternative interface for constructing clientsI see the "pipeline" and "options" parameters as mirrors to the interface issues we faced with "context" and "options" in our endpoint constructors. And I believe we should be able to address these in a similar manner. I'd like to propose we consider constructing clients using an API along these lines instead: let account = std::env::var("COSMOS_ACCOUNT").unwrap();
let master_key = std::env::var("COSMOS_MASTER_KEY").unwrap();
let auth = AuthorizationToken::primary_from_base64(&master_key)?;
// Create a new Cosmos client with a custom policy
let client = CosmosClient::new(account, auth)
.retry_policy(ExamplePolicy::new());This would move all Footnotes
|
|
This requires further discussion, so I opened: |
I did not make Pipeline settable in #527 because I wasn't sure how it should be done in #510. Should it be added to
ClientBuilderandClientlike this. Would we expect someone to callnew_pipelineand then set the retry policies?