-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set user-agent header in PubSub publisher and subscriber (close #37)
- Loading branch information
Showing
8 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
modules/pubsub/src/main/scala/com/snowplowanalytics/snowplow/pubsub/GcpUserAgent.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2023-present Snowplow Analytics Ltd. All rights reserved. | ||
* | ||
* This program is licensed to you under the Snowplow Community License Version 1.0, | ||
* and you may not use this file except in compliance with the Snowplow Community License Version 1.0. | ||
* You may obtain a copy of the Snowplow Community License Version 1.0 at https://docs.snowplow.io/community-license-1.0 | ||
*/ | ||
package com.snowplowanalytics.snowplow.pubsub | ||
|
||
import cats.Show | ||
import cats.implicits._ | ||
import io.circe.generic.semiauto._ | ||
import io.circe.Decoder | ||
import com.google.api.gax.rpc.FixedHeaderProvider | ||
|
||
case class GcpUserAgent(productName: String, productVersion: String) | ||
|
||
object GcpUserAgent { | ||
implicit def gcpUserAgentDecoder: Decoder[GcpUserAgent] = deriveDecoder[GcpUserAgent] | ||
|
||
implicit def showGcpUserAgent: Show[GcpUserAgent] = Show { ua => | ||
s"${ua.productName}/${ua.productVersion} (GPN:Snowplow;)" | ||
} | ||
|
||
def headerProvider(ua: GcpUserAgent): FixedHeaderProvider = | ||
FixedHeaderProvider.create("user-agent", ua.show) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters