Example #1
0
// BuildAgent .
func BuildAgent(system System) *AgentBuilder {
	return &AgentBuilder{
		system:     system,
		cachedsize: gsconfig.Int("gsagent.rpc.sendQ", 1024),
		timeout:    gsconfig.Seconds("gsagent.rpc.timeout", 5),
		reconnect:  gsconfig.Seconds("gsagent.reconnect.delay", 5),
	}
}
Example #2
0
func (dataset *_DataSet) readLoop() {

	timeout := gsconfig.Seconds("tsdb.dataset.sleep", 2)

	timer := time.NewTimer(timeout)

	for {
		val, ok := dataset.cached.Get(dataset.cursor)

		if !ok {
			val, ok = dataset.storage.Read(dataset.cursor)
			if !ok {
				timer.Reset(timeout)
				select {
				case <-timer.C:
					continue
				case <-dataset.closed:
					return
				}
			}
		}

		select {
		case dataset.Q <- val:
		case <-dataset.closed:
			return
		}
	}
}
Example #3
0
// BuildPipeline creaet new pipeline builder
func BuildPipeline(timerTick time.Duration) *PipelineBuilder {
	return &PipelineBuilder{
		timeout:    gsconfig.Seconds("gorpc.timeout", 5),
		cachedsize: gsconfig.Int("gorpc.sendQ", 1024),
		timewheel:  timer.NewWheel(timerTick),
	}
}
Example #4
0
// NewAcceptor create new server channel acceptor
func NewAcceptor(name string, builder *PipelineBuilder) *Acceptor {
	return &Acceptor{
		Log:     gslogger.Get(name),
		builder: builder,
		timeout: gsconfig.Seconds("timeout", 5),
		name:    name,
	}
}
Example #5
0
// BuildProxy create new proxy builder
func BuildProxy(proxy Proxy) *ProxyBuilder {
	gStr := gsconfig.String("gsproxy.dhkey.G", "6849211231874234332173554215962568648211715948614349192108760170867674332076420634857278025209099493881977517436387566623834457627945222750416199306671083")

	pStr := gsconfig.String("gsproxy.dhkey.P", "13196520348498300509170571968898643110806720751219744788129636326922565480984492185368038375211941297871289403061486510064429072584259746910423138674192557")

	G, _ := new(big.Int).SetString(gStr, 0)

	P, _ := new(big.Int).SetString(pStr, 0)

	return &ProxyBuilder{

		laddrF: gsconfig.String("gsproxy.frontend.laddr", ":13512"),

		laddrE: gsconfig.String("gsproxy.backend.laddr", ":15827"),

		timeout: gsconfig.Seconds("gsproxy.rpc.timeout", 5),

		dhkeyResolver: handler.DHKeyResolve(func(device *gorpc.Device) (*handler.DHKey, error) {
			return handler.NewDHKey(G, P), nil
		}),

		proxy: proxy,
	}
}