Documentation ¶
Index ¶
- Constants
- func IndexCommit(db *gorm.DB, dir string) error
- type ConcurrencyLimiter
- type DatabaseConf
- type IndexCoordinate
- type IndexerConf
- type IndexerServer
- func (s *IndexerServer) IndexCoordinates() ([]IndexCoordinate, error)
- func (s *IndexerServer) LoadMirror() error
- func (s *IndexerServer) RefreshAllIndex() error
- func (s *IndexerServer) RefreshAllMirror() error
- func (s *IndexerServer) RefreshIndex(c IndexCoordinate) error
- func (s *IndexerServer) RefreshMirror(h string) error
- func (s *IndexerServer) ServeService() error
- func (s *IndexerServer) ServeWeb() error
Constants ¶
const (
// DefaultLimit is the default concurrency limit
DefaultLimit = 100
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConcurrencyLimiter ¶
type ConcurrencyLimiter struct {
// contains filtered or unexported fields
}
ConcurrencyLimiter object
func NewConcurrencyLimiter ¶
func NewConcurrencyLimiter(limit int) *ConcurrencyLimiter
NewConcurrencyLimiter allocates a new ConcurrencyLimiter
func (*ConcurrencyLimiter) Execute ¶
func (c *ConcurrencyLimiter) Execute(job func()) int
Execute adds a function to the execution queue. if num of go routines allocated by this instance is < limit launch a new go routine to execute job else wait until a go routine becomes available
func (*ConcurrencyLimiter) ExecuteWithTicket ¶
func (c *ConcurrencyLimiter) ExecuteWithTicket(job func(ticket int)) int
ExecuteWithTicket adds a job into an execution queue and returns a ticket id. if num of go routines allocated by this instance is < limit launch a new go routine to execute job else wait until a go routine becomes available
func (*ConcurrencyLimiter) GetNumInProgress ¶
func (c *ConcurrencyLimiter) GetNumInProgress() int32
GetNumInProgress returns a (racy) counter of how many go routines are active right now
func (*ConcurrencyLimiter) Wait ¶
func (c *ConcurrencyLimiter) Wait()
Wait will block all the previously Executed jobs completed running.
IMPORTANT: calling the Wait function while keep calling Execute leads to
un-desired race conditions
type DatabaseConf ¶
type IndexCoordinate ¶
func (IndexCoordinate) String ¶
func (s IndexCoordinate) String() string
type IndexerConf ¶
type IndexerConf struct { Database DatabaseConf Web struct { Addr string } PrimaryMirror string }
type IndexerServer ¶
func NewServer ¶
func NewServer(conf *IndexerConf) (*IndexerServer, error)
func (*IndexerServer) IndexCoordinates ¶
func (s *IndexerServer) IndexCoordinates() ([]IndexCoordinate, error)
func (*IndexerServer) LoadMirror ¶
func (s *IndexerServer) LoadMirror() error
func (*IndexerServer) RefreshAllIndex ¶
func (s *IndexerServer) RefreshAllIndex() error
func (*IndexerServer) RefreshAllMirror ¶
func (s *IndexerServer) RefreshAllMirror() error
func (*IndexerServer) RefreshIndex ¶
func (s *IndexerServer) RefreshIndex(c IndexCoordinate) error
func (*IndexerServer) RefreshMirror ¶
func (s *IndexerServer) RefreshMirror(h string) error
func (*IndexerServer) ServeService ¶
func (s *IndexerServer) ServeService() error
func (*IndexerServer) ServeWeb ¶
func (s *IndexerServer) ServeWeb() error