util

package
v0.0.0-...-e27f3f3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERSION = "0.1"
)

Variables

View Source
var (
	ChunkSizes = []int{
		1 << 4,
		1 << 6,
		1 << 8,
		1 << 10,
		1 << 12,
		1 << 14,
		1 << 16,
		1 << 18,
		1 << 20,
		1 << 22,
		1 << 24,
		1 << 26,
		1 << 28,
	}
)
View Source
var (
	Transport *http.Transport
)

Functions

func BytesToUint16

func BytesToUint16(b []byte) (v uint16)

func BytesToUint32

func BytesToUint32(b []byte) (v uint32)

func BytesToUint64

func BytesToUint64(b []byte) (v uint64)

func Delete

func Delete(url string, jwt security.EncodedJwt) error

func Do

func Do(req *http.Request) (resp *http.Response, err error)

func DownloadUrl

func DownloadUrl(fileUrl string) (filename string, rc io.ReadCloser, e error)

func Get

func Get(url string) ([]byte, error)

func GetBufferStream

func GetBufferStream(url string, values url.Values, allocatedBytes []byte, eachBuffer func([]byte)) error

func GetUrlStream

func GetUrlStream(url string, values url.Values, readFn func(io.Reader) error) error

func GrpcDial

func GrpcDial(ctx context.Context, address string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
func Head(url string) (http.Header, error)

func IsGzippableFileType

func IsGzippableFileType(ext, mtype string) (shouldBeZipped, iAmSure bool)

* Default more not to gzip since gzip can be done on client side.

func ListManage

func ListManage(server string) (leader string, peers []string, err error)

func NewListener

func NewListener(addr string, timeout time.Duration) (net.Listener, error)

func NormalizeUrl

func NormalizeUrl(url string) string

func Post

func Post(url string, values url.Values) ([]byte, error)

func PostBytes

func PostBytes(url string, body []byte) ([]byte, error)

func TestFolderWritable

func TestFolderWritable(folder string) (err error)

func Uint16toBytes

func Uint16toBytes(b []byte, v uint16)

func Uint32toBytes

func Uint32toBytes(b []byte, v uint32)

func Uint64toBytes

func Uint64toBytes(b []byte, v uint64)

func Uint8toBytes

func Uint8toBytes(b []byte, v uint8)

func UnGzipData

func UnGzipData(input []byte) ([]byte, error)

func WriteJsonError

func WriteJsonError(w http.ResponseWriter, r *http.Request, httpStatus int, err error)

func WriteJsonQuiet

func WriteJsonQuiet(w http.ResponseWriter, r *http.Request, httpStatus int, obj interface{})

Types

type BytesPool

type BytesPool struct {
	// contains filtered or unexported fields
}

func NewBytesPool

func NewBytesPool() *BytesPool

func (*BytesPool) Get

func (m *BytesPool) Get(size int) []byte

func (*BytesPool) Put

func (m *BytesPool) Put(b []byte)

func (*BytesPool) String

func (m *BytesPool) String() string

type ClusterStatusResult

type ClusterStatusResult struct {
	IsLeader bool     `json:"IsLeader,omitempty"`
	Leader   string   `json:"Leader,omitempty"`
	Peers    []string `json:"Peers,omitempty"`
}

type Conn

type Conn struct {
	net.Conn
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

Conn wraps a net.Conn, and sets a deadline for every read and write operation.

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Read

func (c *Conn) Read(b []byte) (count int, e error)

func (*Conn) Write

func (c *Conn) Write(b []byte) (count int, e error)

type Listener

type Listener struct {
	net.Listener
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

Listener wraps a net.Listener, and gives a place to store the timeout parameters. On Accept, it will wrap the net.Conn with our own Conn for us.

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

type VIDType

type VIDType uint32

func NewVolumeId

func NewVolumeId(vid string) (VIDType, error)

func (*VIDType) Next

func (vid *VIDType) Next() VIDType

func (*VIDType) String

func (vid *VIDType) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL