Skip to content

Development

Vic Luo edited this page Jun 26, 2016 · 2 revisions

Lug is an extensible backend for software mirror. Generally speaking Lug consists of three packages: config, worker and manager. The way they work together is described below:

  1. Create a config.Config instance and get its value by configInst.parse([]byte)
  2. Create a manager.Manager instance by manager.NewManager(&configInst)
  3. (Internal implementation: NewManager creates workers for each repo and forward related part of config(called repoConfig, map[string]string) to its constructor)
  4. manager.Run(), which blocks current routine
  5. (Internal implementation: manager stucks into a dead loop where manager polls each worker and dispatch works(if they are idle and now - lastSync > repoConfig.Interval) to workers. The interval between each loop is Interval)
  6. Main routine can control manager's behavior by manager.Start(), manager.Stop(), manager.Exit(). All of these actions block until according signals are received by manager, therefore workers may still work for a short time even after manager.Stop() is returned.

See according sections for details:

Clone this wiki locally