Skip to content

Commit

Permalink
Unix Domain Socket: add access with new actors API (#2212)
Browse files Browse the repository at this point in the history
  • Loading branch information
ennru authored Mar 18, 2020
1 parent a7b6a9f commit 696901e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import java.util.concurrent.CompletionStage
import scala.compat.java8.OptionConverters._
import scala.compat.java8.FutureConverters._
import akka.NotUsed
import akka.actor.{ActorSystem, ExtendedActorSystem, Extension, ExtensionId, ExtensionIdProvider}
import akka.stream.alpakka.unixdomainsocket.scaladsl.{UnixDomainSocket => ScalaUnixDomainSocket}
import akka.actor.{ClassicActorSystemProvider, ExtendedActorSystem, Extension, ExtensionId, ExtensionIdProvider}
import akka.stream.javadsl.{Flow, Source}
import akka.stream.Materializer
import akka.util.ByteString
Expand All @@ -25,7 +24,7 @@ object UnixDomainSocket extends ExtensionId[UnixDomainSocket] with ExtensionIdPr
/**
* Represents a prospective UnixDomainSocket server binding.
*/
final class ServerBinding private[akka] (delegate: ScalaUnixDomainSocket.ServerBinding) {
final class ServerBinding private[akka] (delegate: scaladsl.UnixDomainSocket.ServerBinding) {

/**
* The local address of the endpoint bound by the materialization of the `connections` [[akka.stream.javadsl.Source Source]].
Expand All @@ -44,7 +43,7 @@ object UnixDomainSocket extends ExtensionId[UnixDomainSocket] with ExtensionIdPr
/**
* Represents an accepted incoming UnixDomainSocket connection.
*/
final class IncomingConnection private[akka] (delegate: ScalaUnixDomainSocket.IncomingConnection) {
final class IncomingConnection private[akka] (delegate: scaladsl.UnixDomainSocket.IncomingConnection) {

/**
* The local address this connection is bound to.
Expand Down Expand Up @@ -75,7 +74,7 @@ object UnixDomainSocket extends ExtensionId[UnixDomainSocket] with ExtensionIdPr
/**
* Represents a prospective outgoing UnixDomainSocket connection.
*/
final class OutgoingConnection private[akka] (delegate: ScalaUnixDomainSocket.OutgoingConnection) {
final class OutgoingConnection private[akka] (delegate: scaladsl.UnixDomainSocket.OutgoingConnection) {

/**
* The remote address this connection is or will be bound to.
Expand All @@ -88,8 +87,15 @@ object UnixDomainSocket extends ExtensionId[UnixDomainSocket] with ExtensionIdPr
def localAddress: UnixSocketAddress = delegate.localAddress
}

override def get(system: ActorSystem): UnixDomainSocket =
super.get(system)
/**
* Get the UnixDomainSocket extension with the classic actors API.
*/
override def get(system: akka.actor.ActorSystem): UnixDomainSocket = super.apply(system)

/**
* Get the UnixDomainSocket extension with the new actors API.
*/
def get(system: ClassicActorSystemProvider): UnixDomainSocket = super.apply(system.classicSystem)

def lookup(): ExtensionId[_ <: Extension] =
UnixDomainSocket
Expand All @@ -102,7 +108,7 @@ final class UnixDomainSocket(system: ExtendedActorSystem) extends akka.actor.Ext
import UnixDomainSocket._
import akka.dispatch.ExecutionContexts.{sameThreadExecutionContext => ec}

private lazy val delegate: ScalaUnixDomainSocket = ScalaUnixDomainSocket(system)
private lazy val delegate: scaladsl.UnixDomainSocket = scaladsl.UnixDomainSocket(system)

/**
* Creates a [[UnixDomainSocket.ServerBinding]] instance which represents a prospective UnixDomainSocket server binding on the given `endpoint`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package scaladsl
import java.nio.file.Path

import akka.NotUsed
import akka.actor.{ActorSystem, ExtendedActorSystem, Extension, ExtensionId, ExtensionIdProvider}
import akka.actor.{ClassicActorSystemProvider, ExtendedActorSystem, Extension, ExtensionId, ExtensionIdProvider}
import akka.stream._
import akka.stream.alpakka.unixdomainsocket.impl.UnixDomainSocketImpl
import akka.stream.scaladsl.{Flow, Keep, Sink, Source}
Expand All @@ -19,7 +19,15 @@ import scala.concurrent.duration.Duration

object UnixDomainSocket extends ExtensionId[UnixDomainSocket] with ExtensionIdProvider {

def apply()(implicit system: ActorSystem): UnixDomainSocket = super.apply(system)
/**
* Get the UnixDomainSocket extension with the classic actors API.
*/
def apply()(implicit system: akka.actor.ActorSystem): UnixDomainSocket = super.apply(system)

/**
* Get the UnixDomainSocket extension with the new actors API.
*/
def apply(system: ClassicActorSystemProvider): UnixDomainSocket = super.apply(system.classicSystem)

override def createExtension(system: ExtendedActorSystem) =
new UnixDomainSocket(system)
Expand Down

0 comments on commit 696901e

Please sign in to comment.