Ejemplo n.º 1
0
//
// The register.
//
func NewRegister() *Register {
	reg := &Register{make(map[string]*RegisterEntry), decoupler.NewDecoupler(1000, nil, nil)}
	//
	// Start the decoupler.
	//
	go reg.dec.ProcessLoop(1 * time.Second)

	//
	// The decoupler can handle periodic tasks recurring tasks so lets implement a harvester.
	// The harvester will effectively run indefinitely by setting a massive repeat value
	//

	reg.dec.ExecuteEvery(1*time.Second, 2*time.Second, 2147483648, func() (executor.ExecutionResult, error) {
		println("Harvester run.")
		zeit := time.Now()
		for t, v := range reg.data {
			if v.ExpireAfter.Before(zeit) {
				delete(reg.data, t)
				println("Harvester Released ", t)
			}
		}

		return executor.EX_OK, nil
	})

	return reg
}
Ejemplo n.º 2
0
func NewCatLocalServiceProvider() *CatServiceProviderLocal {
	return &CatServiceProviderLocal{nil, decoupler.NewDecoupler(1000, nil, nil)}
}