CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-com-typesafe-akka--akka-actor-2-13

Akka Actor library - a toolkit for building highly concurrent, distributed, and resilient message-driven applications for Java and Scala using the Actor Model.

Overview
Eval results
Files

io.mddocs/

I/O Operations

TCP, UDP, and DNS operations for network communication and I/O management using Akka's reactive I/O layer.

Capabilities

TCP Operations

TCP client and server operations with connection management.

/**
 * TCP extension and operations
 */
object Tcp {  
  // Connection commands
  final case class Connect(
    remoteAddress: InetSocketAddress,
    localAddress: Option[InetSocketAddress] = None,
    options: immutable.Traversable[SocketOption] = Nil,
    timeout: Option[FiniteDuration] = None,
    pullMode: Boolean = false
  ) extends Command

  final case class Bind(
    handler: ActorRef,
    localAddress: InetSocketAddress,
    backlog: Int = 100,
    options: immutable.Traversable[SocketOption] = Nil,
    pullMode: Boolean = false
  ) extends Command

  // Connection events  
  final case class Connected(remoteAddress: InetSocketAddress, localAddress: InetSocketAddress) extends Event
  final case class Bound(localAddress: InetSocketAddress) extends Event
  final case class Received(data: ByteString) extends Event
  
  // Control commands
  case object Close extends Command
  case object Closed extends Event
  final case class Write(data: ByteString, ack: Event = NoAck) extends Command
}

/**
 * I/O extension access
 */
object IO {
  def apply(key: ExtensionKey[_ <: Extension])(implicit system: ActorSystem): ActorRef
}

Usage Examples:

import akka.actor.{Actor, ActorRef, Props}
import akka.io.{IO, Tcp}
import akka.util.ByteString
import java.net.InetSocketAddress

class TcpClient extends Actor {
  import Tcp._
  import context.system
  
  val remote = new InetSocketAddress("localhost", 8080)
  IO(Tcp) ! Connect(remote)
  
  def receive = {
    case Connected(remote, local) =>
      println(s"Connected to $remote from $local")
      val connection = sender()
      connection ! Write(ByteString("Hello Server"))
      
    case Received(data) =>
      println(s"Received: ${data.utf8String}")
      
    case Closed =>
      println("Connection closed")
      context.stop(self)
  }
}

UDP Operations

UDP messaging for connectionless communication.

/**
 * UDP operations and messages
 */
object Udp {
  // Bind command
  final case class Bind(handler: ActorRef, localAddress: InetSocketAddress) extends Command
  
  // Send command
  final case class Send(data: ByteString, target: InetSocketAddress) extends Command
  
  // Events
  final case class Bound(localAddress: InetSocketAddress) extends Event
  final case class Received(data: ByteString, sender: InetSocketAddress) extends Event
}

DNS Resolution

DNS lookup operations for hostname resolution.

/**
 * DNS resolution support
 */
object Dns {
  final case class Resolve(name: String) extends Command
  final case class Resolved(name: String, addresses: immutable.Seq[InetAddress]) extends Event
}

Install with Tessl CLI

npx tessl i tessl/maven-com-typesafe-akka--akka-actor-2-13

docs

actor-behavior.md

actor-lifecycle.md

actor-system.md

events-logging.md

index.md

io.md

messaging.md

routing.md

supervision.md

utilities.md

tile.json