class Beanstalk::Connection
- Beanstalk::Connection
- Reference
- Object
Overview
This class encapsulates a connection to a Beanstalk instance. Note that this class is not thread safe and instances of it should not be shared.
Defined in:
Constant Summary
-
DEFAULT_BUFFER_SIZE =
"2048"
-
A constant for the default buffer size to be used when reading data from the Beanstalk server (in bytes).
-
DEFAULT_CONNECT_TIMEOUT =
"10"
-
Constant for the default socket connect time out setting. This value can be overridden using the BEANSTALK_CR_CONNECT_TIMEOUT environment setting.
-
DEFAULT_HOST =
"localhost"
-
A constant for the default host name.
-
DEFAULT_READ_WAIT_TIME =
"10000"
-
Constant for the default read wait time (in milliseconds).
-
LINE_ENDING =
[13_u8, 10_u8]
-
Constant for the line ending used by Beanstalk commands.
-
STATS_BUFFER_SIZE =
4096
-
Constant for the stats job buffer size.
Constructors
-
.open(server : Server) : Connection
This method creates a Connection object and attempts to connect it to a Beanstalk server instance.
Class Method Summary
-
.buffer_size
Returns the size of the read buffer to be used when fetching data from the server.
-
.open(host : String, port = Server::DEFAULT_PORT)
This method creates a Connection object and attempts to connect it to a Beanstalk server instance.
-
.open
This method creates a Connection object connecting to Beanstalk on localhost and using the default port.
Instance Method Summary
-
#[](name : String)
Retrieves a tube with a given name (i.e.
-
#close
Terminates the connection to the Beanstalk server.
-
#closed?
Used to check if the connection is closed.
-
#default_tube
Fetches the default tube for a Connection (i.e.
-
#open?
Used to check if the connection is open.
-
#receive
Attempts to retrieve data from the Beanstalk server.
-
#receive_job
Attempts to retrieve the data for a job from the Beanstalk server.
-
#receive_stats
A method intended to fetch the response for a stats-job request.
-
#send(data : Slice(UInt8)?, *parameters)
Dispatches a message to the Beanstalk server via the socket connection in the appropriate format.
-
#server : Beanstalk::Server
Fetches details of the server associated with a Connection instance.
-
#socket : Socket
Fetches the socket for a Connection object.
-
#stats
Fetches stats for the server attached to a connection.
Constructor Detail
This method creates a Connection object and attempts to connect it to a Beanstalk server instance.
Class Method Detail
Returns the size of the read buffer to be used when fetching data from the server. This value is determined from an environment variable setting with a fall back to a default.
This method creates a Connection object and attempts to connect it to a Beanstalk server instance.
This method creates a Connection object connecting to Beanstalk on localhost and using the default port.
Instance Method Detail
Retrieves a tube with a given name (i.e. a tube that is set to use and watch the named queue).
Fetches the default tube for a Connection (i.e. a tube using and watching the default queue).
Attempts to retrieve the data for a job from the Beanstalk server. This is a specialized method as retrieving job data is really the only variable fetch from the Beanstalk server.
Dispatches a message to the Beanstalk server via the socket connection in the appropriate format.
Fetches details of the server associated with a Connection instance.
Fetches the socket for a Connection object. Should generally not be accessed directly.