Skip to content

Commit

Permalink
chore: adjust agent header value per spec (#375)
Browse files Browse the repository at this point in the history
Adjust agent header value to be colon delimited and to supply the
service name.
  • Loading branch information
malandis authored Jul 3, 2024
1 parent 106baf7 commit 610ddf9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sdk/src/cache/cache_client_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl CacheClientBuilder<NeedsCredentialProvider> {

impl CacheClientBuilder<ReadyToBuild> {
pub fn build(self) -> MomentoResult<CacheClient> {
let agent_value = &utils::user_agent("sdk");
let agent_value = &utils::user_agent("cache");

let data_channel = utils::connect_channel_lazily_configurable(
&self.0.credential_provider.cache_endpoint,
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/storage/preview_storage_client_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl PreviewStorageClientBuilder<NeedsCredentialProvider> {

impl PreviewStorageClientBuilder<ReadyToBuild> {
pub fn build(self) -> MomentoResult<PreviewStorageClient> {
let agent_value = &utils::user_agent("sdk");
let agent_value = &utils::user_agent("store");

let data_channel = utils::connect_channel_lazily_configurable(
&self.0.credential_provider.storage_endpoint,
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/topics/topic_client_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl TopicClientBuilder<NeedsCredentialProvider> {

impl TopicClientBuilder<ReadyToBuild> {
pub fn build(self) -> MomentoResult<TopicClient> {
let agent_value = &utils::user_agent("sdk");
let agent_value = &utils::user_agent("topic");
let channel = connect_channel_lazily(&self.0.credential_provider.cache_endpoint)?;
let authorized_channel = InterceptedService::new(
channel,
Expand Down
6 changes: 3 additions & 3 deletions sdk/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub(crate) fn connect_channel_lazily_configurable(
}

pub(crate) fn user_agent(user_agent_name: &str) -> String {
format!("rust-{user_agent_name}:{VERSION}")
format!("rust:{user_agent_name}:{VERSION}")
}

pub(crate) fn parse_string(raw: Vec<u8>) -> MomentoResult<String> {
Expand Down Expand Up @@ -352,8 +352,8 @@ mod tests {

#[test]
fn test_user_agent() {
let user_agent_name = "my_app";
let expected_user_agent = format!("rust-{user_agent_name}:{VERSION}");
let user_agent_name = "cache";
let expected_user_agent = format!("rust:{user_agent_name}:{VERSION}");
let result = user_agent(user_agent_name);
assert_eq!(result, expected_user_agent);
}
Expand Down

0 comments on commit 610ddf9

Please sign in to comment.