Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple http pipeline with aggregation #7

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version="2.7.5"
align = none
align.openParenCallSite = false
align.openParenDefnSite = false
align.tokens = []
assumeStandardLibraryStripMargin = false
binPack.parentConstructors = false
continuationIndent.callSite = 2
continuationIndent.defnSite = 2
danglingParentheses = true
docstrings = ScalaDoc
docstrings.blankFirstLine = yes
encoding = UTF-8
importSelectors = singleLine
includeCurlyBraceInSelectChains = true
indentOperator = spray
lineEndings = unix
maxColumn = 80
newlines.alwaysBeforeTopLevelStatements = true
newlines.sometimesBeforeColonInMethodReturnType = false
optIn.breakChainOnFirstMethodDot = true
rewrite.rules = [
PreferCurlyFors
]
spaces {
inImportCurlyBraces = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object Fs2Netty extends IOApp {
val port = Port(args(1).toInt).get

val rsrc = Network[IO] flatMap { net =>
val handlers = net.server(host, port) map { client =>
val handlers = net.server(host, port, options = Nil) map { client =>
client.reads.through(client.writes).attempt.void
}

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ThisBuild / organizationName := "Typelevel"

ThisBuild / startYear := Some(2021)

ThisBuild / crossScalaVersions := Seq("2.12.12", "2.13.4", "3.0.0-M3")
ThisBuild / crossScalaVersions := Seq("2.12.12", "2.13.4") // "3.0.0-M3" temporarily removed to easier/speedier

ThisBuild / githubWorkflowOSes ++= Seq("macos-latest", "windows-latest")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@
* limitations under the License.
*/

package fs2
package netty
package fs2.netty

import com.comcast.ip4s.{IpAddress, SocketAddress}
import fs2.netty.pipeline.socket.Socket
import io.netty.channel.socket.SocketChannel
import io.netty.channel.{Channel, ChannelInitializer}

trait Socket[F[_]] {
trait NettyChannelInitializer[F[_], O, I] {

def localAddress: F[SocketAddress[IpAddress]]
def remoteAddress: F[SocketAddress[IpAddress]]
def toSocketChannelInitializer(
cb: Socket[F, O, I] => F[Unit]
): F[ChannelInitializer[SocketChannel]] =
toChannelInitializer[SocketChannel](cb)

def reads: Stream[F, Byte]

def write(bytes: Chunk[Byte]): F[Unit]
def writes: Pipe[F, Byte, INothing]
def toChannelInitializer[C <: Channel](
cb: Socket[F, O, I] => F[Unit]
): F[ChannelInitializer[C]]
}
Loading