本文整理汇总了Golang中github.com/weaveworks/flux/api.FluxService类的典型用法代码示例。如果您正苦于以下问题:Golang FluxService类的具体用法?Golang FluxService怎么用?Golang FluxService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FluxService类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: handleRegister
func handleRegister(s api.FluxService) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
inst := getInstanceID(r)
// Upgrade to a websocket
ws, err := websocket.Upgrade(w, r, nil)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, err.Error())
return
}
// Set up RPC. The service is a websocket _server_ but an RPC
// _client_.
rpcClient := rpc.NewClient(ws)
// Make platform available to clients
// This should block until the daemon disconnects
// TODO: Handle the error here
s.RegisterDaemon(inst, rpcClient)
// Clean up
// TODO: Handle the error here
rpcClient.Close()
})
}
开发者ID:weaveworks,项目名称:flux,代码行数:26,代码来源:transport.go
示例2: handleHistory
func handleHistory(s api.FluxService) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
inst := getInstanceID(r)
service := mux.Vars(r)["service"]
spec, err := flux.ParseServiceSpec(service)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, errors.Wrapf(err, "parsing service spec %q", spec).Error())
return
}
h, err := s.History(inst, spec)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, err.Error())
return
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
if err := json.NewEncoder(w).Encode(h); err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, err.Error())
return
}
})
}
开发者ID:weaveworks,项目名称:flux,代码行数:26,代码来源:transport.go
示例3: handlePostRelease
func handlePostRelease(s api.FluxService) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var (
inst = getInstanceID(r)
vars = mux.Vars(r)
service = vars["service"]
image = vars["image"]
kind = vars["kind"]
)
serviceSpec, err := flux.ParseServiceSpec(service)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, errors.Wrapf(err, "parsing service spec %q", service).Error())
return
}
imageSpec := flux.ParseImageSpec(image)
releaseKind, err := flux.ParseReleaseKind(kind)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, errors.Wrapf(err, "parsing release kind %q", kind).Error())
return
}
var excludes []flux.ServiceID
for _, ex := range r.URL.Query()["exclude"] {
s, err := flux.ParseServiceID(ex)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, errors.Wrapf(err, "parsing excluded service %q", ex).Error())
return
}
excludes = append(excludes, s)
}
id, err := s.PostRelease(inst, jobs.ReleaseJobParams{
ServiceSpec: serviceSpec,
ImageSpec: imageSpec,
Kind: releaseKind,
Excludes: excludes,
})
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, err.Error())
return
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
if err := json.NewEncoder(w).Encode(postReleaseResponse{
Status: "Queued.",
ReleaseID: id,
}); err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, err.Error())
return
}
})
}
开发者ID:weaveworks,项目名称:flux,代码行数:57,代码来源:transport.go
示例4: handleIsConnected
func handleIsConnected(s api.FluxService) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
inst := getInstanceID(r)
switch s.IsDaemonConnected(inst) {
case platform.ErrPlatformNotAvailable:
w.WriteHeader(http.StatusNotFound)
case nil:
w.WriteHeader(http.StatusNoContent)
default:
w.WriteHeader(http.StatusInternalServerError)
}
return
})
}
开发者ID:weaveworks,项目名称:flux,代码行数:15,代码来源:transport.go
示例5: handleGetRelease
func handleGetRelease(s api.FluxService) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
inst := getInstanceID(r)
id := mux.Vars(r)["id"]
job, err := s.GetRelease(inst, jobs.JobID(id))
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, err.Error())
return
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
if err := json.NewEncoder(w).Encode(job); err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, err.Error())
return
}
})
}
开发者ID:weaveworks,项目名称:flux,代码行数:19,代码来源:transport.go
示例6: handleListServices
func handleListServices(s api.FluxService) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
inst := getInstanceID(r)
namespace := mux.Vars(r)["namespace"]
res, err := s.ListServices(inst, namespace)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, err.Error())
return
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
if err := json.NewEncoder(w).Encode(res); err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, err.Error())
return
}
})
}
开发者ID:weaveworks,项目名称:flux,代码行数:19,代码来源:transport.go
示例7: handleUnlock
func handleUnlock(s api.FluxService) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
inst := getInstanceID(r)
service := mux.Vars(r)["service"]
id, err := flux.ParseServiceID(service)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, errors.Wrapf(err, "parsing service ID %q", id).Error())
return
}
if err = s.Unlock(inst, id); err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, err.Error())
return
}
w.WriteHeader(http.StatusOK)
})
}
开发者ID:weaveworks,项目名称:flux,代码行数:20,代码来源:transport.go
示例8: handleSetConfig
func handleSetConfig(s api.FluxService) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
inst := getInstanceID(r)
var config flux.UnsafeInstanceConfig
if err := json.NewDecoder(r.Body).Decode(&config); err != nil {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, err.Error())
return
}
if err := s.SetConfig(inst, config); err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, err.Error())
return
}
w.WriteHeader(http.StatusOK)
return
})
}
开发者ID:weaveworks,项目名称:flux,代码行数:22,代码来源:transport.go
示例9: handleGetConfig
func handleGetConfig(s api.FluxService) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
inst := getInstanceID(r)
config, err := s.GetConfig(inst)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, err.Error())
return
}
configBytes := bytes.Buffer{}
if err = json.NewEncoder(&configBytes).Encode(config); err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, err.Error())
return
}
w.WriteHeader(http.StatusOK)
w.Write(configBytes.Bytes())
return
})
}
开发者ID:weaveworks,项目名称:flux,代码行数:22,代码来源:transport.go
注:本文中的github.com/weaveworks/flux/api.FluxService类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论