本文整理汇总了Golang中github.com/vulcand/vulcand/proxy.Proxy类的典型用法代码示例。如果您正苦于以下问题:Golang Proxy类的具体用法?Golang Proxy怎么用?Golang Proxy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Proxy类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: initProxySlow
// initProxySlow reads configuration from Etcd piece by piece. That may take
// several minutes on large configurations!
func initProxySlow(ng engine.Engine, p proxy.Proxy) error {
hosts, err := ng.GetHosts()
if err != nil {
return err
}
for _, h := range hosts {
if err := p.UpsertHost(h); err != nil {
return err
}
}
bs, err := ng.GetBackends()
if err != nil {
return err
}
for _, b := range bs {
if err := p.UpsertBackend(b); err != nil {
return err
}
bk := engine.BackendKey{Id: b.Id}
servers, err := ng.GetServers(bk)
if err != nil {
return err
}
for _, s := range servers {
if err := p.UpsertServer(bk, s); err != nil {
return err
}
}
}
ls, err := ng.GetListeners()
if err != nil {
return err
}
for _, l := range ls {
if err := p.UpsertListener(l); err != nil {
return err
}
}
fs, err := ng.GetFrontends()
if err != nil {
return err
}
if len(fs) == 0 {
log.Warningf("No frontends found")
}
for _, f := range fs {
if err := p.UpsertFrontend(f); err != nil {
log.Warningf("Cannot register frontend \"%v\", invalid backend config", f.Id)
continue
}
fk := engine.FrontendKey{Id: f.Id}
ms, err := ng.GetMiddlewares(fk)
if err != nil {
return err
}
for _, m := range ms {
if err := p.UpsertMiddleware(fk, m); err != nil {
log.Warningf("Cannot register frontend \"%v\", invalid middleware config", f.Id)
continue
}
}
}
return nil
}
开发者ID:vulcand,项目名称:vulcand,代码行数:76,代码来源:supervisor.go
示例2: processChange
// processChange takes the backend change notification emitted by the backend and applies it to the server
func processChange(p proxy.Proxy, ch interface{}) error {
switch change := ch.(type) {
case *engine.HostUpserted:
return p.UpsertHost(change.Host)
case *engine.HostDeleted:
return p.DeleteHost(change.HostKey)
case *engine.ListenerUpserted:
return p.UpsertListener(change.Listener)
case *engine.ListenerDeleted:
return p.DeleteListener(change.ListenerKey)
case *engine.FrontendUpserted:
return p.UpsertFrontend(change.Frontend)
case *engine.FrontendDeleted:
return p.DeleteFrontend(change.FrontendKey)
case *engine.MiddlewareUpserted:
return p.UpsertMiddleware(change.FrontendKey, change.Middleware)
case *engine.MiddlewareDeleted:
return p.DeleteMiddleware(change.MiddlewareKey)
case *engine.BackendUpserted:
return p.UpsertBackend(change.Backend)
case *engine.BackendDeleted:
return p.DeleteBackend(change.BackendKey)
case *engine.ServerUpserted:
return p.UpsertServer(change.BackendKey, change.Server)
case *engine.ServerDeleted:
return p.DeleteServer(change.ServerKey)
}
return fmt.Errorf("unsupported change: %#v", ch)
}
开发者ID:vulcand,项目名称:vulcand,代码行数:37,代码来源:supervisor.go
示例3: initProxy
// initProxy reads the configuration from the engine and configures the server
func initProxy(ng engine.Engine, p proxy.Proxy) (uint64, error) {
snapshot, err := ng.GetSnapshot()
if err != nil {
// Some legacy engines do not implement `GetSnapshot` so we resort to
// a slow method of obtaining configuration from Etcd.
if _, ok := err.(*engine.SnapshotNotSupportedError); ok {
return 0, initProxySlow(ng, p)
}
return 0, err
}
for _, h := range snapshot.Hosts {
if err := p.UpsertHost(h); err != nil {
return 0, err
}
}
for _, bs := range snapshot.BackendSpecs {
if err := p.UpsertBackend(bs.Backend); err != nil {
return 0, err
}
for _, server := range bs.Servers {
if err := p.UpsertServer(bs.Backend.GetUniqueId(), server); err != nil {
return 0, err
}
}
}
for _, l := range snapshot.Listeners {
if err := p.UpsertListener(l); err != nil {
return 0, err
}
}
for _, fs := range snapshot.FrontendSpecs {
if err := p.UpsertFrontend(fs.Frontend); err != nil {
return 0, err
}
for _, m := range fs.Middlewares {
if err := p.UpsertMiddleware(fs.Frontend.GetKey(), m); err != nil {
return 0, err
}
}
}
return snapshot.Index, nil
}
开发者ID:vulcand,项目名称:vulcand,代码行数:43,代码来源:supervisor.go
注:本文中的github.com/vulcand/vulcand/proxy.Proxy类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论