本文整理匯總了Golang中github.com/flynn/flynn/router/client.Client類的典型用法代碼示例。如果您正苦於以下問題:Golang Client類的具體用法?Golang Client怎麽用?Golang Client使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Client類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createRoute
func createRoute(db *postgres.DB, rc routerc.Client, appID string, route *router.Route) error {
route.ParentRef = routeParentRef(appID)
if err := schema.Validate(route); err != nil {
return err
}
return rc.CreateRoute(route)
}
示例2: createRoute
func createRoute(app *ct.App, router routerc.Client, route router.Route, r ResponseHelper) {
route.ParentRef = routeParentRef(app)
if err := router.CreateRoute(&route); err != nil {
r.Error(err)
return
}
r.JSON(200, &route)
}
示例3: getRouteList
func getRouteList(app *ct.App, router routerc.Client, r ResponseHelper) {
routes, err := router.ListRoutes(routeParentRef(app))
if err != nil {
r.Error(err)
return
}
r.JSON(200, routes)
}
示例4: streamRouterEvents
func streamRouterEvents(rc routerc.Client, db *postgres.DB, doneCh chan struct{}) error {
// wait for router to come up
{
events := make(chan *discoverd.Event)
stream, err := discoverd.NewService("router-api").Watch(events)
if err != nil {
return err
}
for e := range events {
if e.Kind == discoverd.EventKindUp {
break
}
}
stream.Close()
}
events := make(chan *router.StreamEvent)
s, err := rc.StreamEvents(events)
if err != nil {
return err
}
go func() {
for {
e, ok := <-events
if !ok {
return
}
route := e.Route
route.ID = postgres.CleanUUID(route.ID)
var appID string
if strings.HasPrefix(route.ParentRef, routeParentRefPrefix) {
appID = strings.TrimPrefix(route.ParentRef, routeParentRefPrefix)
}
eventType := ct.EventTypeRoute
if e.Event == "remove" {
eventType = ct.EventTypeRouteDeletion
}
hash := md5.New()
io.WriteString(hash, appID)
io.WriteString(hash, string(eventType))
io.WriteString(hash, route.ID)
io.WriteString(hash, route.CreatedAt.String())
io.WriteString(hash, route.UpdatedAt.String())
uniqueID := fmt.Sprintf("%x", hash.Sum(nil))
if err := createEvent(wrapDBExec(db.Exec), &ct.Event{
AppID: appID,
ObjectID: route.ID,
ObjectType: eventType,
UniqueID: uniqueID,
}, route); err != nil {
log.Println(err)
}
}
}()
_, _ = <-doneCh
return s.Close()
}
示例5: deleteRoute
func deleteRoute(route *router.Route, router routerc.Client, r ResponseHelper) {
err := router.DeleteRoute(route.ID)
if err == routerc.ErrNotFound {
err = ErrNotFound
}
if err != nil {
r.Error(err)
return
}
r.WriteHeader(200)
}
示例6: getRouteMiddleware
func getRouteMiddleware(app *ct.App, c martini.Context, params martini.Params, router routerc.Client, r ResponseHelper) {
route, err := router.GetRoute(routeID(params))
if err == routerc.ErrNotFound || err == nil && route.ParentRef != routeParentRef(app) {
err = ErrNotFound
}
if err != nil {
r.Error(err)
return
}
c.Map(route)
}