本文整理匯總了Golang中github.com/github/git-lfs/config.Configuration.ConcurrentTransfers方法的典型用法代碼示例。如果您正苦於以下問題:Golang Configuration.ConcurrentTransfers方法的具體用法?Golang Configuration.ConcurrentTransfers怎麽用?Golang Configuration.ConcurrentTransfers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/github/git-lfs/config.Configuration
的用法示例。
在下文中一共展示了Configuration.ConcurrentTransfers方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: LogHttpStats
// LogHttpStats is intended to be called after all HTTP operations for the
// commmand have finished. It dumps k/v logs, one line per httpTransfer into
// a log file with the current timestamp.
func LogHttpStats(cfg *config.Configuration) {
if !cfg.IsLoggingStats {
return
}
file, err := statsLogFile()
if err != nil {
fmt.Fprintf(os.Stderr, "Error logging http stats: %s\n", err)
return
}
fmt.Fprintf(file, "concurrent=%d batch=%v time=%d version=%s\n", cfg.ConcurrentTransfers(), cfg.BatchTransfer(), time.Now().Unix(), config.Version)
for key, responses := range httpTransferBuckets {
for _, response := range responses {
stats := httpTransfers[response]
fmt.Fprintf(file, "key=%s reqheader=%d reqbody=%d resheader=%d resbody=%d restime=%d status=%d url=%s\n",
key,
stats.requestStats.HeaderSize,
stats.requestStats.BodySize,
stats.responseStats.HeaderSize,
stats.responseStats.BodySize,
stats.responseStats.Stop.Sub(stats.responseStats.Start).Nanoseconds(),
response.StatusCode,
response.Request.URL)
}
}
fmt.Fprintf(os.Stderr, "HTTP Stats logged to file %s\n", file.Name())
}
示例2: Environ
func Environ(cfg *config.Configuration, manifest *transfer.Manifest) []string {
osEnviron := os.Environ()
env := make([]string, 0, len(osEnviron)+7)
dltransfers := manifest.GetDownloadAdapterNames()
sort.Strings(dltransfers)
ultransfers := manifest.GetUploadAdapterNames()
sort.Strings(ultransfers)
fetchPruneConfig := cfg.FetchPruneConfig()
env = append(env,
fmt.Sprintf("LocalWorkingDir=%s", config.LocalWorkingDir),
fmt.Sprintf("LocalGitDir=%s", config.LocalGitDir),
fmt.Sprintf("LocalGitStorageDir=%s", config.LocalGitStorageDir),
fmt.Sprintf("LocalMediaDir=%s", LocalMediaDir()),
fmt.Sprintf("LocalReferenceDir=%s", config.LocalReferenceDir),
fmt.Sprintf("TempDir=%s", TempDir()),
fmt.Sprintf("ConcurrentTransfers=%d", cfg.ConcurrentTransfers()),
fmt.Sprintf("TusTransfers=%v", cfg.TusTransfersAllowed()),
fmt.Sprintf("BasicTransfersOnly=%v", cfg.BasicTransfersOnly()),
fmt.Sprintf("BatchTransfer=%v", cfg.BatchTransfer()),
fmt.Sprintf("SkipDownloadErrors=%v", cfg.SkipDownloadErrors()),
fmt.Sprintf("FetchRecentAlways=%v", fetchPruneConfig.FetchRecentAlways),
fmt.Sprintf("FetchRecentRefsDays=%d", fetchPruneConfig.FetchRecentRefsDays),
fmt.Sprintf("FetchRecentCommitsDays=%d", fetchPruneConfig.FetchRecentCommitsDays),
fmt.Sprintf("FetchRecentRefsIncludeRemotes=%v", fetchPruneConfig.FetchRecentRefsIncludeRemotes),
fmt.Sprintf("PruneOffsetDays=%d", fetchPruneConfig.PruneOffsetDays),
fmt.Sprintf("PruneVerifyRemoteAlways=%v", fetchPruneConfig.PruneVerifyRemoteAlways),
fmt.Sprintf("PruneRemoteName=%s", fetchPruneConfig.PruneRemoteName),
fmt.Sprintf("AccessDownload=%s", cfg.Access("download")),
fmt.Sprintf("AccessUpload=%s", cfg.Access("upload")),
fmt.Sprintf("DownloadTransfers=%s", strings.Join(dltransfers, ",")),
fmt.Sprintf("UploadTransfers=%s", strings.Join(ultransfers, ",")),
)
if len(cfg.FetchExcludePaths()) > 0 {
env = append(env, fmt.Sprintf("FetchExclude=%s", strings.Join(cfg.FetchExcludePaths(), ", ")))
}
if len(cfg.FetchIncludePaths()) > 0 {
env = append(env, fmt.Sprintf("FetchInclude=%s", strings.Join(cfg.FetchIncludePaths(), ", ")))
}
for _, ext := range cfg.Extensions() {
env = append(env, fmt.Sprintf("Extension[%d]=%s", ext.Priority, ext.Name))
}
for _, e := range osEnviron {
if !strings.Contains(e, "GIT_") {
continue
}
env = append(env, e)
}
return env
}
示例3: NewHttpClient
// NewHttpClient returns a new HttpClient for the given host (which may be "host:port")
func NewHttpClient(c *config.Configuration, host string) *HttpClient {
httpClientsMutex.Lock()
defer httpClientsMutex.Unlock()
if httpClients == nil {
httpClients = make(map[string]*HttpClient)
}
if client, ok := httpClients[host]; ok {
return client
}
dialtime := c.Git.Int("lfs.dialtimeout", 30)
keepalivetime := c.Git.Int("lfs.keepalive", 1800) // 30 minutes
tlstime := c.Git.Int("lfs.tlstimeout", 30)
tr := &http.Transport{
Proxy: ProxyFromGitConfigOrEnvironment(c),
Dial: (&net.Dialer{
Timeout: time.Duration(dialtime) * time.Second,
KeepAlive: time.Duration(keepalivetime) * time.Second,
}).Dial,
TLSHandshakeTimeout: time.Duration(tlstime) * time.Second,
MaxIdleConnsPerHost: c.ConcurrentTransfers(),
}
tr.TLSClientConfig = &tls.Config{}
if isCertVerificationDisabledForHost(c, host) {
tr.TLSClientConfig.InsecureSkipVerify = true
} else {
tr.TLSClientConfig.RootCAs = getRootCAsForHost(c, host)
}
client := &HttpClient{
Config: c,
Client: &http.Client{Transport: tr, CheckRedirect: CheckRedirect},
}
httpClients[host] = client
return client
}