util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const Github404 = GithubError("github: 404")

Variables

View Source
var (
	// Wg Concurrency control
	Wg sync.WaitGroup
)

Functions

func Execute

func Execute()

Execute the main processing logic

func GetBody

func GetBody(url string) (body []byte, err error)

func Test

func Test(ctx *Context) (err error)

Types

type CDN

type CDN struct {
	// contains filtered or unexported fields
}

func NewCDN

func NewCDN(buildCache bool, mirrorURL string) (cdn *CDN)

func (*CDN) WarmUp

func (cdn *CDN) WarmUp(path string) (err error)

type ChangeAction

type ChangeAction struct {
	Type    string `json:"type"`
	Package string `json:"package"`
	Time    int    `json:"time"`
}

func NewChangeAction

func NewChangeAction(type_ string, packageName string, time int) *ChangeAction

func NewChangeActionFromJSONString

func NewChangeActionFromJSONString(jsonString string) (action *ChangeAction, err error)

func (*ChangeAction) ToJSONString

func (action *ChangeAction) ToJSONString() string

type Changes

type Changes struct {
	Timestamp int            `json:"timestamp"`
	Actions   []ChangeAction `json:"actions"`
}

type Config

type Config struct {
	UserAgent            string `yaml:"USER_AGENT"`
	RedisAddr            string `yaml:"REDIS_ADDR"`
	RedisPassword        string `yaml:"REDIS_PASSWORD"`
	RedisDB              int    `yaml:"REDIS_DB"`
	OSSAccessKeyID       string `yaml:"OSS_ACCESS_KEY_ID"`
	OSSAccessKeySecret   string `yaml:"OSS_ACCESS_KEY_SECRET"`
	OSSEndpoint          string `yaml:"OSS_ENDPOINT"`
	OSSBucket            string `yaml:"OSS_BUCKET"`
	GithubToken          string `yaml:"GITHUB_TOKEN"`
	MirrorUrl            string `yaml:"MIRROR_URL"`
	RepoUrl              string `yaml:"REPO_URL"`
	ApiUrl               string `yaml:"API_URL"`
	ProviderUrl          string `yaml:"PROVIDER_URL"`
	DistUrl              string `yaml:"DIST_URL"`
	BuildCache           string `yaml:"BUILD_CACHE"`
	ApiIterationInterval int    `yaml:"API_ITERATION_INTERVAL"`
}

Config Mirror Config

func LoadConfig

func LoadConfig(configPath string) (conf *Config, err error)

func (*Config) ValidateConfig

func (config *Config) ValidateConfig() (err error)

type Context

type Context struct {
	// contains filtered or unexported fields
}

func NewContext

func NewContext(conf *Config) (ctx *Context, err error)

func (*Context) SyncComposerPhar

func (ctx *Context) SyncComposerPhar(processName string)

func (*Context) SyncDists

func (ctx *Context) SyncDists(processName string)

func (*Context) SyncDistsRetry

func (ctx *Context) SyncDistsRetry(processName string)

func (*Context) SyncPackagesJsonFile

func (ctx *Context) SyncPackagesJsonFile(processName string)

func (*Context) SyncPackagesV1

func (ctx *Context) SyncPackagesV1(processName string)

func (*Context) SyncPackagesV2

func (ctx *Context) SyncPackagesV2(processName string)

func (*Context) SyncProvider

func (ctx *Context) SyncProvider(processName string)

func (*Context) SyncStatus

func (ctx *Context) SyncStatus(processName string)

func (*Context) SyncV2

func (ctx *Context) SyncV2(processName string)

type Dist

type Dist struct {
	Path string `json:"path"`
	Url  string `json:"url"`
}

func NewDist

func NewDist(path, url string) *Dist

func NewDistFromJSONString

func NewDistFromJSONString(jsonString string) (dist *Dist, err error)

func (*Dist) ToJSONString

func (dist *Dist) ToJSONString() string

type Github

type Github struct {
	// contains filtered or unexported fields
}

func NewGithub

func NewGithub(token, userAgent string) (github *Github)

func (*Github) GetDist

func (github *Github) GetDist(url string) (resp *http.Response, err error)

func (*Github) Test

func (github *Github) Test() (err error)

type GithubError

type GithubError string

func (GithubError) Error

func (e GithubError) Error() string

type Hashes

type Hashes struct {
	SHA256 string `json:"sha256"`
}

type Mirror

type Mirror struct {
	// contains filtered or unexported fields
}

func NewMirror

func NewMirror(providerUrl string, distUrl string, apiIterationInterval int) (mirror *Mirror)

type MyLogger

type MyLogger struct {
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(prefix string) (logger *MyLogger)

func (*MyLogger) Error

func (logger *MyLogger) Error(message string)

func (*MyLogger) Info

func (logger *MyLogger) Info(message string)

type Package

type Package struct {
	Name string      `json:"name"`
	Dist PackageDist `json:"dist"`
}

type PackageDist

type PackageDist struct {
	Type      string `json:"type"`
	Url       string `json:"url"`
	Reference string `json:"reference"`
	Shasum    string `json:"shasum"`
}

type Packages

type Packages struct {
	NotifyBatch      string            `json:"notify-batch"`
	ProviderIncludes map[string]Hashes `json:"provider-includes"`
}

type Packagist

type Packagist struct {
	// contains filtered or unexported fields
}

func NewPackagist

func NewPackagist(repoUrl string, apiUrl string, userAgent string) (packagist *Packagist)

func (*Packagist) Get

func (packagist *Packagist) Get(path string) (content []byte, err error)

func (*Packagist) GetAllPackages

func (packagist *Packagist) GetAllPackages() (content []byte, err error)

func (*Packagist) GetInitTimestamp

func (packagist *Packagist) GetInitTimestamp() (timestamp string, err error)

func (*Packagist) GetMetadataChanges

func (packagist *Packagist) GetMetadataChanges(lastTimestamp string) (changes Changes, err error)

func (*Packagist) GetPackage

func (packagist *Packagist) GetPackage(packageName string) (content []byte, err error)

func (*Packagist) GetPackagesJSON

func (packagist *Packagist) GetPackagesJSON() (body []byte, lastModified string, err error)

type Providers

type Providers struct {
	Providers map[string]Hashes `json:"providers"`
}

func NewProvidersFromJSONString

func NewProvidersFromJSONString(jsonString string) (providers *Providers, err error)

type Response

type Response struct {
	Packages map[string]map[string]Package `json:"packages"`
}

type Stable

type Stable struct {
	Path    string `json:"path"`
	Version string `json:"version"`
	MinPhp  int    `json:"min-php"`
}

type Task

type Task struct {
	Key  string `json:"key"`
	Path string `json:"path"`
	Hash string `json:"hash"`
}

func NewTask

func NewTask(key, path, hash string) *Task

func NewTaskFromJSONString

func NewTaskFromJSONString(jsonString string) (task *Task, err error)

Jump to

Keyboard shortcuts

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