Documentation ¶
Index ¶
- Constants
- func WriteHTTP(conn net.Conn, data []byte) error
- func WriteMessage(w io.Writer, message []byte) error
- func WriteWebSocket(conn net.Conn, data []byte) error
- type Conn
- func (conn *Conn) Close() error
- func (conn *Conn) Do(command string) ([]byte, error)
- func (conn *Conn) ReadMessage() (message []byte, err error)
- func (conn *Conn) Reader() io.Reader
- func (conn *Conn) Server() (ServerStats, error)
- func (conn *Conn) SetDeadline(t time.Time) error
- func (conn *Conn) SetReadDeadline(t time.Time) error
- func (conn *Conn) SetWriteDeadline(t time.Time) error
- type Pool
- type Proto
- type ServerStats
- type Standard
Examples ¶
Constants ¶
const LiveJSON = `{"ok":true,"live":true}`
LiveJSON is the value returned when a connection goes "live".
const MaxMessageSize = 0x1FFFFFFF // 536,870,911 bytes
MaxMessageSize is maximum accepted message size
Variables ¶
This section is empty.
Functions ¶
func WriteMessage ¶
WriteMessage write a message to an io.Writer
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents a connection to a tile38 server.
func Dial ¶
Dial connects to a tile38 server.
Example ¶
conn, err := Dial("localhost:9851") if err != nil { log.Fatal(err) } defer conn.Close() resp, err := conn.Do("set fleet truck1 point 33.5123 -112.2693") if err != nil { log.Fatal(err) } fmt.Println(string(resp))
Output:
func DialTimeout ¶
DialTimeout connects to a tile38 server with a timeout.
func (*Conn) ReadMessage ¶
ReadMessage returns the next message. Used when reading live connections
func (*Conn) Server ¶
func (conn *Conn) Server() (ServerStats, error)
Server returns tile38 server statistics.
func (*Conn) SetDeadline ¶
SetDeadline sets the connection deadline for reads and writes.
func (*Conn) SetReadDeadline ¶
SetDeadline sets the connection deadline for reads.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool represents a pool of tile38 connections.
func DialPool ¶
DialPool creates a new pool with 5 initial connections to the specified tile38 server.
Example ¶
pool, err := DialPool("localhost:9851") if err != nil { log.Fatal(err) } defer pool.Close() // We'll set a point in a background routine go func() { conn, err := pool.Get() // get a conn from the pool if err != nil { log.Fatal(err) } defer conn.Close() // return the conn to the pool _, err = conn.Do("set fleet truck1 point 33.5123 -112.2693") if err != nil { log.Fatal(err) } }() time.Sleep(time.Second / 2) // wait a moment // Retrieve the point we just set. go func() { conn, err := pool.Get() // get a conn from the pool if err != nil { log.Fatal(err) } defer conn.Close() // return the conn to the pool resp, err := conn.Do("get fleet truck1 point") if err != nil { log.Fatal(err) } fmt.Println(string(resp)) }() time.Sleep(time.Second / 2) // wait a moment
Output:
type ServerStats ¶
type ServerStats struct { Standard Stats struct { ServerID string `json:"id"` Following string `json:"following"` AOFSize int `json:"aof_size"` NumCollections int `json:"num_collections"` InMemorySize int `json:"in_memory_size"` NumPoints int `json:"num_points"` NumObjects int `json:"num_objects"` HeapSize int `json:"heap_size"` AvgItemSize int `json:"avg_item_size"` PointerSize int `json:"pointer_size"` } `json:"stats"` }
ServerStats represents tile38 server statistics.