net.ty.pipeline

Utilities to build and work with Netty pipelines

*channel*

dynamic

Thread-local binding for a channel

->byte-order

multimethod

Concerts to a ByteOrder

add-last

(add-last pipeline nick handler)

build-pipeline

(build-pipeline handlers chan)

Build a pipeline from a list of handlers. Binds *channel* to the given chan argument and runs through handlers.

When handlers are functions, call them with no arguments, otherwise add them directly to the ChannelHandler list.

Yields an array of ChannelHandler instances

channel-initializer

(channel-initializer pipeline)

Build a channel initializer from a pipeline, expressed as a sequence of ChannelHandler, see build-pipeline for how to express this.

ChannelActive

protocol

Implement this protocol when you want your adapter to be notified for channel activation.

members

channel-active

(channel-active this ctx)

Called when the channel becomes active

ChannelInactive

protocol

Implement this protocol when you want your adapter to be notified for channel deactivation.

members

channel-inactive

(channel-inactive this ctx)

Called when the channel becomes inactive

ChannelReadComplete

protocol

Implement this protocol when you want your adapter to be notified of a read complete status.

members

channel-read-complete

(channel-read-complete this ctx)

Called when read has completed

ChannelRegistered

protocol

Implement this protocol when you want your adapter to be notified for channel registration.

members

channel-registered

(channel-registered this ctx)

Called upon channel registration

ChannelUnregistered

protocol

Implement this protocol when you want your adapter to be notified for channel deregistration.

members

channel-unregistered

(channel-unregistered this ctx)

Called when channel is deregistered

ChannelWritabilityChanged

protocol

Implement this protocol when you want your adapter to be notified of changes in channel writability.

members

channel-writability-changed

(channel-writability-changed this ctx)

Called when writability has changed on a channel

charset->charset-util

multimethod

converts to a CharsetUtil

defdecoder

macro

(defdecoder sym [msg ctx shareable?] & body)

Define decoders

defencoder

macro

(defencoder sym [msg ctx shareable?] & body)

Define encoder

ExceptionCaught

protocol

Implement this protocol when you want your adapter to be notified of channel exception.

members

exception-caught

(exception-caught this ctx e)

Called for channel exceptions

flush!

(flush! ctx)

Flush context

HandlerAdapter

protocol

This is the minimum an adapter must implement to be proxied to a valid ChannelHandlerAdapter

members

channel-read

(channel-read this ctx input)

Called for each new payload on a channel

IsSharable

protocol

Implement this protocol for adapters when you want to report whether the adapter can be shared or not. When not implemented adapters will be deemed unsharable.

While it may look more natural to write sharable as shareable, it is apparently valid english and is the way netty spells it out.

members

is-sharable?

(is-sharable? this)

Returns whether the handler adapter is sharable

length-field-based-frame-decoder

(length-field-based-frame-decoder)(length-field-based-frame-decoder {:keys [byte-order max offset length adjust strip fail-fast?]})

Create a length field based frame decoder.

length-field-prepender

(length-field-prepender)(length-field-prepender {:keys [length byte-order adjust includes-length?]})

Creates an encoder that adds length-fields

line-based-frame-decoder

(line-based-frame-decoder)(line-based-frame-decoder max-length)(line-based-frame-decoder max-length strip-delimiter?)(line-based-frame-decoder max-length strip-delimiter? fail-fast?)

Builds a ChannelHandler which parses lines.

line-frame-encoder

(line-frame-encoder)

Encode outbound payloads as lines, appending telnet-style carriage returns

make-handler-adapter

(make-handler-adapter adapter)

From an implemenation of net.ty.pipeline.HandlerAdapater, yield a proxied ChannelInboundHandlerAdapter.

Adapters may optionally implement any or all of the following protocols: IsSharable, ChannelActive, ChannelInactive, ChannelReadComplete, ChannelRegistered, ChannelUnregistered, ExceptionCaught, ChannelWritabilityChanged, and UserEventTriggered.

To circumvent CLJ-1814 we cover the most common cases and otherwise build a set of known operations to avoid calling satisfies? at runtime.

read-timeout-handler

(read-timeout-handler timeout unit)(read-timeout-handler timeout)

Build a ChannelHandler which times-out when no payload is read

string-decoder

(string-decoder)(string-decoder charset)

A decoder that coerces to string

string-encoder

(string-encoder)(string-encoder charset)

A encoder that coerces from strings

supported-signatures

(supported-signatures ap)

unit->time-unit

multimethod

Converts to a java util concurrent TimeUnit

UserEventTriggered

protocol

Implement this protocol when you want your adapter to be notified of user events.

members

user-event-triggered

(user-event-triggered this ctx event)

Called when a user event has been triggered on a channel

with-input

macro

(with-input [ctx input] & body)

Inline definition of a ChannelInboundHandlerAdapter which captures context and input and executes body.

write!

(write! ctx msg)

Write message to context

write-and-flush!

(write-and-flush! ctx msg)

Write message to context, then flush context