Documentation
¶
Overview ¶
Package bloomd provides a client abstraction around the BloomD interface.
Example:
client := bloomd.NewClient("10.0.0.30:8673") filter := bloomd.Filter{Name: "coolfilter"} if err := bloomd.CreateFilter(filter); err != nil { // handle error } filters, _ := bloomd.ListFilters() fmt.Printf("%+v", filters["coolfilter"])
Index ¶
- type BloomdError
- type Client
- type Connection
- type Filter
- func (f *Filter) Bulk(keys []string) (responses []bool, err error)
- func (f *Filter) Check(key string) (bool, error)
- func (f *Filter) Clear() error
- func (f *Filter) Close() error
- func (f *Filter) Drop() error
- func (f *Filter) Flush() error
- func (f *Filter) Info() (map[string]string, error)
- func (f *Filter) Multi(keys []string) (responses []bool, err error)
- func (f *Filter) Set(key string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BloomdError ¶
type BloomdError struct {
ErrorString string
}
BloomdError struct
func (*BloomdError) Error ¶
func (err *BloomdError) Error() string
Error returns the internal error representation
type Client ¶
type Client struct { Server string Timeout int Conn *Connection ServerInfo string InfoTime int HashKeys bool }
Client struct is the main entry point to interact with a bloomd server. If using multiple BloomD servers, it is recommended to use a BloomD Ring and only use the proxy as the Server field for your client.
func (*Client) CreateFilter ¶
CreateFilter creates a new filter with provided parameters
type Connection ¶
type Connection struct { Server string Timeout time.Duration Socket *net.TCPConn File *os.File Attempts int Reader *bufio.Reader }
Connection materializes a concrete connection to bloomd
func (*Connection) Read ¶
func (c *Connection) Read() (line string, err error)
Read returns a single line from the socket file
func (*Connection) ReadBlock ¶
func (c *Connection) ReadBlock() (lines []string, err error)
ReadBlock reads a response block from the server. The servers responses are between `start` and `end` which can be optionally provided. Returns an array of the lines within the block.
func (*Connection) Send ¶
func (c *Connection) Send(cmd string) error
Send sends a command to the server
func (*Connection) SendAndReceive ¶
func (c *Connection) SendAndReceive(cmd string) (string, error)
SendAndReceive is a convenience wrapper around `send` and `read`. Sends a command, and reads the response, performing a retry if necessary.
type Filter ¶
type Filter struct { Name string Conn *Connection HashKeys bool // Optional Capacity int // The initial capacity of the filter Prob float64 // The inital probability of false positives InMemory bool // If True, specified that the filter should be created }
Filter represents a bloom filter