apki

package
v0.0.0-...-016837d Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLimit is the default concurrency limit
	DefaultLimit = 100
)

Variables

This section is empty.

Functions

func IndexCommit

func IndexCommit(db *gorm.DB, dir string) error

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 DatabaseConf struct {
	Type        string
	URL         string
	AutoMigrate bool
}

type IndexCoordinate

type IndexCoordinate struct {
	Branch string
	Repo   string
	Arch   string
}

func (IndexCoordinate) String

func (s IndexCoordinate) String() string

type IndexerConf

type IndexerConf struct {
	Database DatabaseConf
	Web      struct {
		Addr string
	}
	PrimaryMirror string
}

type IndexerServer

type IndexerServer struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

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

Directories

Path Synopsis
go get github.com/fatih/gomodifytags
go get github.com/fatih/gomodifytags

Jump to

Keyboard shortcuts

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