Documentation ¶
Index ¶
- Constants
- Variables
- func ParseBulkMessage(line []byte) ([]byte, error)
- func ParseRequest(r *bufio.Reader) (method string, args [][]byte, err error)
- func ReadNextFull(writeTo *bytes.Buffer, r *bufio.Reader) error
- func SubscribeResponse(command string, channel []byte) []byte
- type Dialer
- type DirectDialer
- type Listener
- type PublishCommand
- type Pubsub
- type Request
- type SentinelDialer
- type Server
- type Writable
Constants ¶
const ( // MessageError is the prefix for Redis line errors in the protocol. MessageError = '-' // MessageStatus is the prefix for Redis line statues in the protocol. MessageStatus = '+' // MessageInt is the prefix for Redis line integers in the protocol. // It's followed by the plain text number MessageInt = ':' // MessageBulk is the prefix for Redis bulk messages. It's followed by the // bulk message size, and CRLF, and then the full bulk message bytes. MessageBulk = '$' // MessageMutli is the prefix for Redis "multi" messages (arrays). // It's followed by the array length, and CRLF, and then the next N messages // as elements of the array/ MessageMutli = '*' )
Variables ¶
var ( // ErrWrongMessage is returned in Parse commands if the command // is not a pubsub command. ErrWrongMessage = errors.New("redplex/protocol: unexpected message type") )
Functions ¶
func ParseBulkMessage ¶
ParseBulkMessage expects that the byte slice starts with the length delimiter, and returns the contained message. Does not include the trailing delimiter.
func ParseRequest ¶
ParseRequest parses a method and arguments from the reader.
func ReadNextFull ¶
ReadNextFull copies the next full command from the reader to the buffer.
func SubscribeResponse ¶
SubscribeResponse returns an appropriate response to the given subscribe or unsubscribe command.
Types ¶
type Dialer ¶
type Dialer interface { // Dial attempts to create a connection to the server. Dial() (net.Conn, error) }
The Dialer is a type that can create a TCP connection to the Redis server.
type DirectDialer ¶
type DirectDialer struct {
// contains filtered or unexported fields
}
DirectDialer creates a direct connection to a single Redis server or IP.
func NewDirectDialer ¶
func NewDirectDialer(network string, address string, password string, useTLS bool, timeout time.Duration) DirectDialer
NewDirectDialer creates a DirectDialer that dials to the given address. If the timeout is 0, a default value of 5 seconds will be used.
type PublishCommand ¶
PublishCommand is returned from ParsePublishCommand.
func ParsePublishCommand ¶
func ParsePublishCommand(b []byte) (cmd PublishCommand, err error)
ParsePublishCommand parses the given pubsub command efficiently. Returns a NotPubsubError if the command isn't a pubsub command.
type Pubsub ¶
type Pubsub struct {
// contains filtered or unexported fields
}
Pubsub manages the connection of redplex to the remote pubsub server.
func (*Pubsub) Close ¶
func (p *Pubsub) Close()
Close frees resources associated with the pubsub server.
func (*Pubsub) Start ¶
func (p *Pubsub) Start()
Start creates a pubsub listener to proxy connection data.
func (*Pubsub) Unsubscribe ¶
Unsubscribe removes the listener from the channel.
func (*Pubsub) UnsubscribeAll ¶
UnsubscribeAll removes all channels the writer is subscribed to.
type Request ¶
type Request []byte
Request is a byte slice with utility methods for building up Redis commands.
func NewRequest ¶
NewRequest creates a new request to send to the Redis server.
type SentinelDialer ¶
type SentinelDialer struct {
// contains filtered or unexported fields
}
The SentinelDialer dials into the Redis cluster master as defined by the assortment of sentinel servers.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the redplex server which accepts connections and talks to the underlying Pubsub implementation.