Documentation ¶
Index ¶
- Constants
- Variables
- func CheckAdddress(urlStr string) (string, error)
- func GetSingleIPAddress(addrStr string) (net.IP, error)
- func InvokeWithTimer(m Callable, timer *time.Timer) (interface{}, error)
- func IsExternalAddr(addrStr string) bool
- func ResolveHostDomain(domainName string) ([]net.IP, error)
- type AddressType
- type Callable
- type ChannelPipe
- type MultiListener
- type PipeEventListener
- type PressableQueue
- func (q *PressableQueue) Empty() bool
- func (q *PressableQueue) Full() bool
- func (q *PressableQueue) Offer(e interface{}) bool
- func (q *PressableQueue) Peek() interface{}
- func (q *PressableQueue) Poll() interface{}
- func (q *PressableQueue) Press(e interface{}) interface{}
- func (q *PressableQueue) Size() int
- type StatListener
Constants ¶
const ( DN = `^([a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62}){1}(\.[a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62})*[\._]?$` IPv4 = `^((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])` IPv6 = `` /* 659-byte string literal not displayed */ )
Variables ¶
var ( DNPattern = regexp.MustCompile(DN) InvalidAddresss = fmt.Errorf("invalid address") )
Functions ¶
func CheckAdddress ¶ added in v0.9.0
func GetSingleIPAddress ¶ added in v0.9.0
IGetSingleIPAddress find and get ip address of given address string. It return first ip if DNS or /etc/hosts has multiple IPs
func InvokeWithTimer ¶
InvokeWithTimer call DoCall method of m and return if m is finished or return error if timer fires.
func IsExternalAddr ¶ added in v0.9.0
Types ¶
type AddressType ¶ added in v0.9.0
type AddressType int
const ( AddressTypeError AddressType = iota AddressTypeIP AddressTypeFQDN )
AddressType
func CheckAdddressType ¶ added in v0.9.0
func CheckAdddressType(urlStr string) AddressType
type Callable ¶
type Callable interface { // DoCall run function. it should put result anything if call is over. It also stop function if Cancel was called as soon as possible DoCall(done chan<- interface{}) // Cancel should return instanly Cancel() }
Callable
type ChannelPipe ¶
type ChannelPipe interface { // Put item to pipe. it should be used after Open() method is called. // It always returns true and gurranty that item is queued. Put(item interface{}) bool Out() <-chan interface{} // Done should be called after get item from out channel Done() Open() Close() }
ChannelPipe serve non blocking limited size channel. It preserve input ordering, and not block caller unless it is Closed() Tt must be called Open before using it, and Close for dispose resource.
func NewDefaultChannelPipe ¶
func NewDefaultChannelPipe(bufsize int, listener PipeEventListener) ChannelPipe
NewDefaultChannelPipe create pipe to output channel out
type MultiListener ¶
type MultiListener struct {
// contains filtered or unexported fields
}
MultiListener can contain multiple unit listeners and toss events
func NewMultiListener ¶
func NewMultiListener(ls ...PipeEventListener) *MultiListener
func (*MultiListener) AppendListener ¶
func (ml *MultiListener) AppendListener(l PipeEventListener)
func (*MultiListener) OnDrop ¶
func (ml *MultiListener) OnDrop(element interface{})
func (*MultiListener) OnIn ¶
func (ml *MultiListener) OnIn(element interface{})
func (*MultiListener) OnOut ¶
func (ml *MultiListener) OnOut(element interface{})
type PipeEventListener ¶
type PipeEventListener interface { // OnIn is called when item is queued OnIn(element interface{}) // OnDrop is called when queued item is dropped and not out to channel receiver OnDrop(element interface{}) // OnOut is called when queued item went to out channel (and will be sent to receiver) OnOut(element interface{}) }
PipeEventListener listen event of ChannelPipe
type PressableQueue ¶
type PressableQueue struct {
// contains filtered or unexported fields
}
PressableQueue non-threadsafe fixed size queue, implemented like circular queue
func NewPressableQueue ¶
func NewPressableQueue(capacity int) *PressableQueue
NewPressableQueue create a new queue
func (*PressableQueue) Empty ¶
func (q *PressableQueue) Empty() bool
Empty returns true if queue has no element, or false if not
func (*PressableQueue) Full ¶
func (q *PressableQueue) Full() bool
Full returns true if queue has maximum number of elements, or false if not
func (*PressableQueue) Offer ¶
func (q *PressableQueue) Offer(e interface{}) bool
Offer is adding element to queue, it returns true if add success, or false if queue if add fail.
func (*PressableQueue) Peek ¶
func (q *PressableQueue) Peek() interface{}
Peek return first element but not delete in queue. It returns nil if queue is empty
func (*PressableQueue) Poll ¶
func (q *PressableQueue) Poll() interface{}
Poll return first element and remove it in queue. It returns nil if queue is empty
func (*PressableQueue) Press ¶
func (q *PressableQueue) Press(e interface{}) interface{}
Press is adding element to queue and return nil fi queue is not full, or drop first element and return dropped element if queue is full.
func (*PressableQueue) Size ¶
func (q *PressableQueue) Size() int
Size return the number of element queue has
type StatListener ¶
type StatListener struct {
// contains filtered or unexported fields
}
StatListener make summation
func NewStatLister ¶
func NewStatLister() *StatListener
func (*StatListener) OnDrop ¶
func (l *StatListener) OnDrop(element interface{})
func (*StatListener) OnIn ¶
func (l *StatListener) OnIn(element interface{})
func (*StatListener) OnOut ¶
func (l *StatListener) OnOut(element interface{})