forked from akka/alpakka
-
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.
Introducing Akka stream attributes in order to configure http request a…
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
azure-storage/src/main/scala/akka/stream/alpakka/azure/storage/StorageAttributes.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,38 @@ | ||
/* | ||
* Copyright (C) since 2016 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package akka.stream.alpakka | ||
package azure | ||
package storage | ||
|
||
import akka.stream.Attributes | ||
import akka.stream.Attributes.Attribute | ||
|
||
/** | ||
* Akka Stream attributes that are used when materializing AzureStorage stream blueprints. | ||
*/ | ||
object StorageAttributes { | ||
|
||
/** | ||
* Settings to use for the S3 stream | ||
*/ | ||
def settings(settings: StorageSettings): Attributes = Attributes(StorageSettingsValue(settings)) | ||
|
||
/** | ||
* Config path which will be used to resolve required AzureStorage settings | ||
*/ | ||
def settingsPath(path: String): Attributes = Attributes(StorageSettingsPath(path)) | ||
} | ||
|
||
final class StorageSettingsPath private (val path: String) extends Attribute | ||
object StorageSettingsPath { | ||
val Default: StorageSettingsPath = StorageSettingsPath(StorageSettings.ConfigPath) | ||
|
||
def apply(path: String) = new StorageSettingsPath(path) | ||
} | ||
|
||
final class StorageSettingsValue private (val settings: StorageSettings) extends Attribute | ||
object StorageSettingsValue { | ||
def apply(settings: StorageSettings) = new StorageSettingsValue(settings) | ||
} |
42 changes: 42 additions & 0 deletions
42
azure-storage/src/main/scala/akka/stream/alpakka/azure/storage/StorageExt.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,42 @@ | ||
/* | ||
* Copyright (C) since 2016 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package akka.stream.alpakka | ||
package azure | ||
package storage | ||
|
||
import akka.actor.{ | ||
ActorSystem, | ||
ClassicActorSystemProvider, | ||
ExtendedActorSystem, | ||
Extension, | ||
ExtensionId, | ||
ExtensionIdProvider | ||
} | ||
|
||
/** | ||
* Manages one [[StorageSettings]] per `ActorSystem`. | ||
*/ | ||
final class StorageExt private (sys: ExtendedActorSystem) extends Extension { | ||
val settings: StorageSettings = settings(StorageSettings.ConfigPath) | ||
|
||
def settings(prefix: String): StorageSettings = StorageSettings(sys.settings.config.getConfig(prefix)) | ||
} | ||
|
||
object StorageExt extends ExtensionId[StorageExt] with ExtensionIdProvider { | ||
override def lookup: StorageExt.type = StorageExt | ||
override def createExtension(system: ExtendedActorSystem) = new StorageExt(system) | ||
|
||
/** | ||
* Java API. | ||
* Get the Storage extension with the classic actors API. | ||
*/ | ||
override def get(system: ActorSystem): StorageExt = super.apply(system) | ||
|
||
/** | ||
* Java API. | ||
* Get the Storage extension with the new actors API. | ||
*/ | ||
override def get(system: ClassicActorSystemProvider): StorageExt = super.apply(system) | ||
} |