basekit

package module
v0.0.0-...-b347bf8 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

README

basekit

The commonly used go language development kit

License Go Report Card GoDoc Build Status

Some usual toolkit,include:

pub-sub

Just mediate implemention in memory(publish:Topic,subscribe:channel)

singleflight

only duplicate of singleflight in groupcache

svc

program init,start,safe exit

hash

  • consistent:
  • hrw:provides an implementation of Highest Random Weight hashing, an alternative to consistent hashing which is both simple and fast

other

  • counter:multithreading counter
  • waitwraper:a wrapper for simplify calling for waitgroup

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

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

Counter counter is a multi-thread safe counters

func NewCounter

func NewCounter() *Counter

NewCounter counter constructor

func (*Counter) AddOne

func (c *Counter) AddOne() int

AddOne 在原内部计数基础上,+1。

func (*Counter) Current

func (c *Counter) Current() int

Current 获取当前内部计数结果。

func (*Counter) DecOne

func (c *Counter) DecOne() int

DecOne 在原内部计数基础上,-1。

func (*Counter) MaxNum

func (c *Counter) MaxNum() int

MaxNum 计数器生存周期内,最大的计数。

func (*Counter) Reset

func (c *Counter) Reset()

Reset 重置计数器

type WaitWraper

type WaitWraper struct {
	sync.WaitGroup
}

WaitWraper is a method wrapper based sync.Waitgroup

func (*WaitWraper) Wrap

func (w *WaitWraper) Wrap(fn func())

Wrap encapsulates the method fn with sync.Waitgroup to ensure its execution.

Example
fn := func() {
	fmt.Println("this just example for wrap!")
}
ww := WaitWraper{}
ww.Wrap(fn)
ww.Wait()
Output:


this just example for wrap!

Directories

Path Synopsis
container
omap
Package omap 通过红黑树实现了高效率的有序map。
Package omap 通过红黑树实现了高效率的有序map。
hash
consistent
package consistent 提供了一致性哈希的计算功能,以用于分布式请求的负载均衡。
package consistent 提供了一致性哈希的计算功能,以用于分布式请求的负载均衡。
hrw
Package hrw provides an implementation of Highest Random Weight hashing, an alternative to consistent hashing which is both simple and fast.
Package hrw provides an implementation of Highest Random Weight hashing, an alternative to consistent hashing which is both simple and fast.
这个包提供服务端加解密的基本方法。
这个包提供服务端加解密的基本方法。
Package pubsub is a simple subscription service module that provides asynchronous message distribution based on single computer memory
Package pubsub is a simple subscription service module that provides asynchronous message distribution based on single computer memory
Package singleflight provide a duplicate function call suppression mechisam.
Package singleflight provide a duplicate function call suppression mechisam.
提供运行程序的启动、停止的框架,标准化信号拦截的运行分块。
提供运行程序的启动、停止的框架,标准化信号拦截的运行分块。

Jump to

Keyboard shortcuts

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