id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c27400
// Open store. if err := s.Open(); err != nil { return err } m.store = s // If peers then set peer set. if len(m.peers) > 0 { if err := s.SetPeers(m.peers); err != nil { return fmt.Errorf("set peers: %s", err) } } return nil }
c27401
} else { s.SetStore(&server.ProxyStore{Peers: m.peers}) } if err := s.ListenAndServe(); err != nil { return err } m.dnsServer = s return nil }
c27402
else { h.Store = m.store } m.handler = h m.httpServer = &http.Server{Handler: h} // Create listener via mux // HTTP listens to all methods: CONNECT, DELETE, GET, HEAD, OPTIONS, POST, PUT, TRACE. httpLn := m.mux.Listen([]byte{'C', 'D', 'G', 'H', 'O', 'P', 'T'}) go m.httpServer.Serve(httpLn) return nil }
c27403
res, err := http.Post(notifyURL, "application/json", bytes.NewReader(payload)) if err != nil { m.logger.Printf("failed to notify: %s", err) } else { res.Body.Close() } }
c27404
port, _ := net.SplitHostPort(portAddr) return net.JoinHostPort(host, port) }
c27405
case <-timeoutCh: return errors.New("timed out waiting for leader") case <-time.After(100 * time.Millisecond): if leader := m.store.Leader(); leader != "" { return nil } } } }
c27406
continue } other = append(other, s) } return other }
c27407
i, peer := range peers { host, _, err := net.SplitHostPort(peer) if err != nil { return nil, err } other[i] = net.JoinHostPort(host, port) } return other, nil }
c27408
if _, err := io.Copy(&cert, res.Body); err != nil { return nil, err } return cert.Bytes(), nil }
c27409
{ return errors.New("controller: missing old domain") } return c.Put("/domain", dm, dm) }
c27410
c.Post("/artifacts", artifact, artifact) }
c27411
error { release.AppID = appID return c.Post("/releases", release, release) }
c27412
c.Post("/apps", app, app) }
c27413
} return c.Post(fmt.Sprintf("/apps/%s", app.ID), app, app) }
c27414
} var e ct.AppDeletionEvent if err := json.Unmarshal(event.Data, &e); err != nil { return nil, err } if e.Error != "" { return nil, errors.New(e.Error) } return e.AppDeletion, nil case <-time.After(60 * time.Second): return nil, errors.New("timed out waiting for app deletion") } }
c27415
c.Post("/providers", provider, provider) }
c27416
provider := &ct.Provider{} return provider, c.Get(fmt.Sprintf("/providers/%s", providerID), provider) }
c27417
&ct.Resource{} err := c.Post(fmt.Sprintf("/providers/%s/resources", req.ProviderID), req, res) return res, err }
c27418
err := c.Get(fmt.Sprintf("/providers/%s/resources/%s", providerID, resourceID), res) return res, err }
c27419
{ var resources []*ct.Resource return resources, c.Get("/resources", &resources) }
c27420
resources, c.Get(fmt.Sprintf("/providers/%s/resources", providerID), &resources) }
c27421
resource, c.Put(fmt.Sprintf("/providers/%s/resources/%s/apps/%s", providerID, resourceID, appID), nil, &resource) }
c27422
resource, c.Delete(fmt.Sprintf("/providers/%s/resources/%s/apps/%s", providerID, resourceID, appID), &resource) }
c27423
return resources, c.Get(fmt.Sprintf("/apps/%s/resources", appID), &resources) }
c27424
return c.Put(fmt.Sprintf("/providers/%s/resources/%s", resource.ProviderID, resource.ID), resource, resource) }
c27425
res := &ct.Resource{} err := c.Delete(fmt.Sprintf("/providers/%s/resources/%s", providerID, resourceID), res) return res, err }
c27426
return c.Put(fmt.Sprintf("/apps/%s/formations/%s", formation.AppID, formation.ReleaseID), formation, formation) }
c27427
return c.Put(fmt.Sprintf("/apps/%s/jobs/%s", job.AppID, job.UUID), job, job) }
c27428
{ return c.Delete(fmt.Sprintf("/apps/%s/jobs/%s", appID, jobID), nil) }
c27429
{ return c.Put(fmt.Sprintf("/apps/%s/release", appID), &ct.Release{ID: releaseID}, nil) }
c27430
release := &ct.Release{} return release, c.Get(fmt.Sprintf("/apps/%s/release", appID), release) }
c27431
var routes []*router.Route return routes, c.Get(fmt.Sprintf("/apps/%s/routes", appID), &routes) }
c27432
{ route := &router.Route{} return route, c.Get(fmt.Sprintf("/apps/%s/routes/%s", appID, routeID), route) }
c27433
c.Post(fmt.Sprintf("/apps/%s/routes", appID), route, route) }
c27434
c.Put(fmt.Sprintf("/apps/%s/routes/%s", appID, routeID), route, route) }
c27435
c.Delete(fmt.Sprintf("/apps/%s/routes/%s", appID, routeID), nil) }
c27436
formation, c.Get(fmt.Sprintf("/apps/%s/formations/%s", appID, releaseID), formation) }
c27437
return formation, c.Get(fmt.Sprintf("/apps/%s/formations/%s?expand=true", appID, releaseID), formation) }
c27438
formations, c.Get(fmt.Sprintf("/apps/%s/formations", appID), &formations) }
c27439
{ return c.Delete(fmt.Sprintf("/apps/%s/formations/%s", appID, releaseID), nil) }
c27440
release := &ct.Release{} return release, c.Get(fmt.Sprintf("/releases/%s", releaseID), release) }
c27441
artifact := &ct.Artifact{} return artifact, c.Get(fmt.Sprintf("/artifacts/%s", artifactID), artifact) }
c27442
{ app := &ct.App{} return app, c.Get(fmt.Sprintf("/apps/%s", appID), app) }
c27443
} res, err := c.RawReq("GET", path, nil, nil, nil) if err != nil { return nil, err } return res.Body, nil }
c27444
if opts != nil { if encodedQuery := opts.EncodedQuery(); encodedQuery != "" { path = fmt.Sprintf("%s?%s", path, encodedQuery) } } return c.Stream("GET", path, nil, output) }
c27445
{ res := &ct.Deployment{} return res, c.Get(fmt.Sprintf("/deployments/%s", deploymentID), res) }
c27446
deployments, c.Get(fmt.Sprintf("/apps/%s/deployments", appID), &deployments) }
c27447
return c.StreamEvents(ct.StreamEventsOptions{ AppID: appID, ObjectTypes: []ct.EventType{ct.EventTypeJob}, }, appEvents) }
c27448
c.Hijack("POST", fmt.Sprintf("/apps/%s/jobs", appID), http.Header{"Upgrade": {"flynn-attach/0"}}, job) }
c27449
c.Post(fmt.Sprintf("/apps/%s/jobs", appID), req, job) }
c27450
{ job := &ct.Job{} return job, c.Get(fmt.Sprintf("/apps/%s/jobs/%s", appID, jobID), job) }
c27451
var jobs []*ct.Job return jobs, c.Get(fmt.Sprintf("/apps/%s/jobs", appID), &jobs) }
c27452
{ var jobs []*ct.Job return jobs, c.Get("/active-jobs", &jobs) }
c27453
[]*ct.App return apps, c.Get("/apps", &apps) }
c27454
return artifacts, c.Get("/artifacts", &artifacts) }
c27455
{ var releases []*ct.Release return releases, c.Get("/releases", &releases) }
c27456
var releases []*ct.Release return releases, c.Get(fmt.Sprintf("/apps/%s/releases", appID), &releases) }
c27457
return providers, c.Get("/providers", &providers) }
c27458
} vol := &ct.Volume{} return vol, c.Get(fmt.Sprintf("/apps/%s/volumes/%s", appID, id), vol) }
c27459
} return c.Put(fmt.Sprintf("/volumes/%s", vol.ID), vol, vol) }
c27460
{ var volumes []*ct.Volume return volumes, c.Get("/volumes", &volumes) }
c27461
[]*ct.Volume return volumes, c.Get(fmt.Sprintf("/apps/%s/volumes", appID), &volumes) }
c27462
} return c.Put(fmt.Sprintf("/apps/%s/volumes/%s/decommission", appID, vol.ID), &vol, &vol) }
c27463
:= since.UTC().Format(time.RFC3339Nano) return c.Stream("GET", "/volumes?since="+t, nil, output) }
c27464
"/backup", nil, nil, nil) if err != nil { return nil, err } return res.Body, nil }
c27465
:= &ct.ClusterBackup{} return b, c.Get("/backup", b) }
c27466
return nil, stream.Err() } var e ct.ReleaseDeletionEvent if err := json.Unmarshal(event.Data, &e); err != nil { return nil, err } if e.Error != "" { return nil, errors.New(e.Error) } return e.ReleaseDeletion, nil case <-time.After(60 * time.Second): return nil, errors.New("timed out waiting fo...
c27467
return c.Post(fmt.Sprintf("/apps/%s/gc", appID), nil, nil) }
c27468
err := c.Get(status.Path, s); err != nil { return nil, err } return &s.Data, nil }
c27469
c.Post("/sinks", sink, sink) }
c27470
{ sink := &ct.Sink{} return sink, c.Get(fmt.Sprintf("/sinks/%s", sinkID), sink) }
c27471
{ sink := &ct.Sink{} return sink, c.Delete(fmt.Sprintf("/sinks/%s", sinkID), sink) }
c27472
[]*ct.Sink return sinks, c.Get("/sinks", &sinks) }
c27473
i, known = w.instances[inst.ID] identical = known && i.Equal(inst) w.instances[inst.ID] = inst return }
c27474
delete(w.instances, inst.ID) }
c27475
if job.State == JobStateBlocked && job.TagsMatchHost(host) { job.State = JobStatePending go s.StartJob(job) } } }
c27476
if vol.ReleaseID != job.ReleaseID { continue } if vol.JobType != job.Type { continue } if vol.Path != req.Path { continue } // skip if the volume is assigned to another job if vol.JobID != nil && *vol.JobID != job.ID { continue } // skip if we have already assigned the job to a host ...
c27477
job := range s.jobs { if job.IsRunning() && job.IsInApp(appID) { activeReleases[job.Formation.Release.ID] = struct{}{} } } return len(activeReleases) }
c27478
// the slice we are iterating over) if none of the // above cases match, preferring starting jobs to // running ones if found == nil || found.State == JobStateRunning && job.State == JobStateStarting { found = job } } } if found == nil { return nil, fmt.Errorf("no %s jobs running", typ) } re...
c27479
id = random.UUID() if err := ioutil.WriteFile(path, []byte(id), 0644); err != nil { return "", fmt.Errorf("error writing instance ID: %s", err) } return id, nil }
c27480
= m } if curr, ok := m[h.ID()]; ok && curr.StartedAt.Before(j.StartedAt) { continue } jobCopy := j m[h.ID()] = &jobCopy } } sort.Sort(sortReleases) res := make([]map[string]*host.Job, len(sortReleases)) for i, r := range sortReleases { res[i] = make(map[string]*host.Job, len(releases[r.id]))...
c27481
range allowOriginPatterns { allowed, _ = regexp.MatchString(pattern, origin) if allowed { return } } return }
c27482
-1) pattern = strings.Replace(pattern, "\\?", ".", -1) allowOriginPatterns = append(allowOriginPatterns, "^"+pattern+"$") } return func(w http.ResponseWriter, req *http.Request) { if origin := req.Header.Get(headerOrigin); origin != "" { for key, value := range o.Header(origin, req) { w.Header().Set(ke...
c27483
"--pgdata", p.dataDir, "--username=postgres", "--encoding=UTF-8", "--locale=en_US.UTF-8", )) return p.writeHBAConf() }
c27484
{ path, err := d.downloadGzippedFile(conf, dir, false) if err != nil { return nil, err } paths[conf] = path } return paths, nil }
c27485
if len(ids) != 2 || ids[0] == "" || ids[1] == "" { return "", errors.New("invalid ID") } return ids[0], nil }
c27486
= random.UUID() } return hostID + "-" + uuid }
c27487
once.Do(func() { close(stopCh); <-doneCh }) } go p.waitForSyncInner(downstream, stopCh, doneCh) }
c27488
info.Addrs = []string{p.addr()} info.Database = "admin" info.Username = "flynn" info.Password = p.Password } return info }
c27489
n := copy(b, p.connBuf) p.connBuf = p.connBuf[n:] if len(p.connBuf) == 0 { p.connBuf = nil } if len(b) == n { return n, nil } readN, err := p.Conn.Read(b[n:]) return readN + n, err } return p.Conn.Read(b) }
c27490
msgc: make(chan *rfc5424.Message, 1000), pausec: make(chan struct{}), } go a.run() return a }
c27491
[]*rfc5424.Message { return a.getBuffer(id).Read() }
c27492
make([][]*rfc5424.Message, 0, len(a.buffers)) for _, buf := range a.buffers { buffers = append(buffers, buf.Read()) } return buffers }
c27493
{ return a.getBuffer(id).ReadAndSubscribe(msgc, donec) }
c27494
for k, buf := range a.buffers { buf.Close() delete(a.buffers, k) } }
c27495
a.getBuffer(id).Subscribe(msgc, donec) }
c27496
fmt.Fprintf(w, "%04x%s", len(s)+4, s) return err }
c27497
h.router.POST("/clusters", h.servePostCluster) h.router.DELETE("/clusters", h.serveDeleteCluster) h.router.GET("/ping", h.serveGetPing) return h }
c27498
id, tags: tags, c: &httpclient.Client{ ErrNotFound: ErrNotFound, URL: addr, HTTP: h, }, } }
c27499
var jobs map[string]host.ActiveJob err := c.c.Get("/host/jobs", &jobs) return jobs, err }