slimta.edge

Package defining a common interface upon which a message can be received on a listening socket under various protocols.

class slimta.edge.Edge(queue[, hostname=None])

Bases: object

This class should be used as the base for all edge services. Most will directly inherit EdgeServer and thus indirectly inherit Edge.

Parameters:
  • queueQueue (Or Queue-like) object that will take responsibility for delivery of messages received by the Edge.
  • hostname – String identifying the local machine, stamped to each received message in its receiver attribute for use in headers and bounce messages. By default, the return value of getfqdn() is used.
handoff(envelope)

This method may be called manually or by whatever mechanism a sub-class uses to receive new Envelope messages from a client. Because a QueuePolicy may generate new Envelope objects, this method returns a list of tuples, (envelope, result) where result is either an ID string or a QueueError. The edge service can then use this information to report back success or failure to the client.

Parameters:envelopeEnvelope containing the received message.
Returns:List of tuples containing each Envelope and its corresponding ID string or QueueError.
kill()

New in version 0.3.15.

This method is used by Edge and Edge-like objects to properly end associated services (such as running Greenlet threads) and close resources.

class slimta.edge.EdgeServer(listener, queue[, pool=None[, hostname=None]])

Bases: slimta.edge.Edge, gevent._greenlet.Greenlet

This class implements a Greenlet serving a StreamServer until killed. Connections are accepted on the socket and passed to handle(), which should be overridden by implementers of this base class. The socket will be closed automatically.

Parameters:
  • queueQueue object used by handoff() to ensure the envelope is properly queued before acknowledged by the edge service.
  • listener – Usually a (ip, port) tuple defining the interface and port upon which to listen for connections. See the listener parameter to BaseServer for more information.
  • pool – If given, defines a specific gevent.pool.Pool to use for new greenlets.
  • hostname – String identifying the local machine. See Edge for more details.
handle(socket, address)

Override this function to receive messages on the socket and call handoff() with each received Envelope object.

Parameters:
  • socket – The socket for the connected client.
  • address – The address of the connected client.
Raises:

NotImplementedError

kill()

New in version 0.3.15.

This method is used by Edge and Edge-like objects to properly end associated services (such as running Greenlet threads) and close resources.


Sub-Modules: