mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* Bump github.com/alicebob/miniredis/v2 from 2.21.0 to 2.34.0 Bumps [github.com/alicebob/miniredis/v2](https://github.com/alicebob/miniredis) from 2.21.0 to 2.34.0. - [Release notes](https://github.com/alicebob/miniredis/releases) - [Changelog](https://github.com/alicebob/miniredis/blob/master/CHANGELOG.md) - [Commits](https://github.com/alicebob/miniredis/compare/v2.21.0...v2.34.0) --- updated-dependencies: - dependency-name: github.com/alicebob/miniredis/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Update serverless gomod --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: tempo-gh-bot[bot] <[email protected]>
61 lines
916 B
Go
61 lines
916 B
Go
package proto
|
|
|
|
import (
|
|
"bufio"
|
|
"crypto/tls"
|
|
"net"
|
|
)
|
|
|
|
type Client struct {
|
|
c net.Conn
|
|
r *bufio.Reader
|
|
}
|
|
|
|
func Dial(addr string) (*Client, error) {
|
|
c, err := net.Dial("tcp", addr)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &Client{
|
|
c: c,
|
|
r: bufio.NewReader(c),
|
|
}, nil
|
|
}
|
|
|
|
func DialTLS(addr string, cfg *tls.Config) (*Client, error) {
|
|
c, err := tls.Dial("tcp", addr, cfg)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &Client{
|
|
c: c,
|
|
r: bufio.NewReader(c),
|
|
}, nil
|
|
}
|
|
|
|
func (c *Client) Close() error {
|
|
return c.c.Close()
|
|
}
|
|
|
|
func (c *Client) Do(cmd ...string) (string, error) {
|
|
if err := Write(c.c, cmd); err != nil {
|
|
return "", err
|
|
}
|
|
return Read(c.r)
|
|
}
|
|
|
|
func (c *Client) Read() (string, error) {
|
|
return Read(c.r)
|
|
}
|
|
|
|
// Do() + ReadStrings()
|
|
func (c *Client) DoStrings(cmd ...string) ([]string, error) {
|
|
res, err := c.Do(cmd...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ReadStrings(res)
|
|
}
|