utils

package
v0.0.0-...-d8a2fef Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2016 License: BSD-3-Clause Imports: 9 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// ErrNone is none error
	ErrNone = 100
	// ErrTopicNotExisted is topic not existed error
	ErrTopicNotExisted = 101
	// ErrLineNotExisted is line not existed error
	ErrLineNotExisted = 102
	// ErrNotDelivered is the message not delivered error
	ErrNotDelivered = 103
	// ErrBadKey is key bad error
	ErrBadKey = 104
	// ErrTopicExisted is topic has been existed error
	ErrTopicExisted = 105
	// ErrLineExisted is line has been existed error
	ErrLineExisted = 106
	// ErrBadRequest is bad request error
	ErrBadRequest = 400
	// ErrInternalError is internal error
	ErrInternalError = 500
)

Variables

This section is empty.

Functions

func Acati

func Acati(str, b string, n int) string

Acati implements string cat int

func Acatui

func Acatui(str, b string, n uint64) string

Acatui implements string cat uint64

func Addrcat

func Addrcat(host string, port int) string

Addrcat implements net address cat

func AllowMethod

func AllowMethod(w http.ResponseWriter, m string, ms ...string) bool

AllowMethod verifies that the given method is one of the allowed methods, and if not, it writes an error to w. A boolean is returned indicating whether or not the method is allowed.

func Atoi

func Atoi(str string) uint64

Atoi implements cached atoi

func ItoaQuick

func ItoaQuick(i int) string

ItoaQuick returns the cached itoa string

func NewLimitedBufferReader

func NewLimitedBufferReader(r io.Reader, n int) io.Reader

NewLimitedBufferReader returns a reader that reads from the given reader but limits the amount of data returned to at most n bytes.

Types

type Error

type Error struct {
	ErrorCode int    `json:"errorCode"`
	Message   string `json:"message"`
	Cause     string `json:"cause,omitempty"`
}

Error is the error type in uq

func NewError

func NewError(errorCode int, cause string) *Error

NewError returns a uq error

func (Error) Error

func (e Error) Error() string

Only for error interface

func (Error) WriteTo

func (e Error) WriteTo(w http.ResponseWriter)

WriteTo writes the error to a http response

type StopListener

type StopListener struct {
	*net.TCPListener //Wrapped listener
	// contains filtered or unexported fields
}

StopListener is a stopable listener

func NewStopListener

func NewStopListener(l net.Listener) (*StopListener, error)

NewStopListener returns a new StopListener with a net listener

func (*StopListener) Accept

func (sl *StopListener) Accept() (net.Conn, error)

Accept implements the Accept interface

func (*StopListener) Stop

func (sl *StopListener) Stop()

Stop implements the Stop interface

Jump to

Keyboard shortcuts

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