本文整理匯總了Golang中github.com/mailgun/vulcand/plugin/registry.GetRegistry函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetRegistry函數的具體用法?Golang GetRegistry怎麽用?Golang GetRegistry使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetRegistry函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetUpTest
func (s *ApiSuite) SetUpTest(c *C) {
s.backend = membackend.NewMemBackend(registry.GetRegistry())
muxRouter := mux.NewRouter()
hostRouter := hostroute.NewHostRouter()
proxy, err := vulcan.NewProxy(hostRouter)
configurator := configure.NewConfigurator(proxy)
c.Assert(err, IsNil)
InitProxyController(s.backend, adapter.NewAdapter(proxy), configurator.GetConnWatcher(), muxRouter)
s.testServer = httptest.NewServer(muxRouter)
s.client = NewClient(s.testServer.URL, registry.GetRegistry())
}
示例2: SetUpTest
func (s *ApiSuite) SetUpTest(c *C) {
newProxy := func(id int) (proxy.Proxy, error) {
return proxy.New(id, stapler.New(), proxy.Options{})
}
s.ng = memng.New(registry.GetRegistry())
sv := supervisor.New(newProxy, s.ng, make(chan error), supervisor.Options{})
app := scroll.NewApp()
InitProxyController(s.ng, sv, app)
s.testServer = httptest.NewServer(app.GetHandler())
s.client = NewClient(s.testServer.URL, registry.GetRegistry())
}
示例3: TestHostsFromJson
func (s *BackendSuite) TestHostsFromJson(c *C) {
h, err := NewHost("localhost")
c.Assert(err, IsNil)
up, err := NewUpstream("up1")
c.Assert(err, IsNil)
e, err := NewEndpoint("u1", "e1", "http://localhost")
c.Assert(err, IsNil)
l, err := NewLocation("localhost", "loc1", "/path", "up1")
c.Assert(err, IsNil)
cl, err := connlimit.NewConnLimit(10, "client.ip")
c.Assert(err, IsNil)
i := &MiddlewareInstance{Id: "c1", Type: "connlimit", Middleware: cl}
up.Endpoints = []*Endpoint{e}
l.Upstream = up
l.Middlewares = []*MiddlewareInstance{i}
h.Locations = []*Location{l}
hosts := []*Host{h}
bytes, err := json.Marshal(map[string]interface{}{"Hosts": hosts})
out, err := HostsFromJson(bytes, registry.GetRegistry().GetSpec)
c.Assert(err, IsNil)
c.Assert(out, NotNil)
c.Assert(out, DeepEquals, hosts)
}
示例4: SetUpTest
func (s *MemSuite) SetUpTest(c *C) {
engine := New(registry.GetRegistry())
s.suite.ChangesC = make(chan interface{})
s.stopC = make(chan bool)
go engine.Subscribe(s.suite.ChangesC, s.stopC)
s.suite.Engine = engine
}
示例5: main
func main() {
log.InitWithConfig(log.Config{Name: "console"})
cmd := command.NewCommand(registry.GetRegistry())
err := cmd.Run(os.Args)
if err != nil {
log.Errorf("error: %s\n", err)
}
}
示例6: run
func (s *CmdSuite) run(params ...string) string {
args := []string{"vctl"}
args = append(args, params...)
args = append(args, fmt.Sprintf("--vulcan=%s", s.testServer.URL))
s.out = &bytes.Buffer{}
s.cmd = &Command{registry: registry.GetRegistry(), out: s.out, vulcanUrl: s.testServer.URL}
s.cmd.Run(args)
return strings.Replace(s.out.String(), "\n", " ", -1)
}
示例7: SetUpTest
func (s *CmdSuite) SetUpTest(c *C) {
s.ng = memng.New(registry.GetRegistry())
newProxy := func(id int) (proxy.Proxy, error) {
return proxy.New(id, stapler.New(), proxy.Options{})
}
sv := supervisor.New(newProxy, s.ng, make(chan error), supervisor.Options{})
sv.Start()
s.sv = sv
app := scroll.NewApp()
api.InitProxyController(s.ng, sv, app)
s.testServer = httptest.NewServer(app.GetHandler())
s.out = &bytes.Buffer{}
s.cmd = &Command{registry: registry.GetRegistry(), out: s.out, vulcanUrl: s.testServer.URL}
}
示例8: main
func main() {
log.Init([]*log.LogConfig{&log.LogConfig{Name: "console"}})
cmd := command.NewCommand(registry.GetRegistry())
err := cmd.Run(os.Args)
if err != nil {
log.Errorf("Error: %s\n", err)
}
}
示例9: main
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
if err := service.Run(registry.GetRegistry()); err != nil {
fmt.Printf("Service exited with error: %s\n", err)
os.Exit(255)
} else {
fmt.Println("Service exited gracefully")
}
}
示例10: SetUpTest
func (s *S) SetUpTest(c *check.C) {
var err error
s.conn, err = db.Conn()
c.Assert(err, check.IsNil)
dbtest.ClearAllCollections(s.conn.Collection("router_vulcand_tests").Database)
s.engine = memng.New(registry.GetRegistry())
scrollApp := scroll.NewApp()
api.InitProxyController(s.engine, &supervisor.Supervisor{}, scrollApp)
s.vulcandServer = httptest.NewServer(scrollApp.GetHandler())
config.Set("routers:vulcand:api-url", s.vulcandServer.URL)
}
示例11: SetUpTest
func (s *SupervisorSuite) SetUpTest(c *C) {
s.ng = memng.New(registry.GetRegistry()).(*memng.Mem)
s.errorC = make(chan error)
s.clock = &timetools.FreezedTime{
CurrentTime: time.Date(2012, 3, 4, 5, 6, 7, 0, time.UTC),
}
s.sv = New(newProxy, s.ng, s.errorC, Options{Clock: s.clock})
}
示例12: TestMiddlewareCRUD
func (s *ApiSuite) TestMiddlewareCRUD(c *C) {
_, err := s.client.AddUpstream("up1")
c.Assert(err, IsNil)
_, err = s.client.AddHost("localhost")
c.Assert(err, IsNil)
loc, err := s.client.AddLocation("localhost", "la", "/home", "up1")
c.Assert(err, IsNil)
c.Assert(loc, NotNil)
cl := s.makeConnLimit("c1", 10, "client.ip", 2, loc)
out, err := s.client.AddMiddleware(registry.GetRegistry().GetSpec(cl.Type), loc.Hostname, loc.Id, cl)
c.Assert(err, IsNil)
c.Assert(out, NotNil)
c.Assert(out.Id, Equals, cl.Id)
c.Assert(out.Priority, Equals, cl.Priority)
hosts, err := s.client.GetHosts()
c.Assert(err, IsNil)
m := hosts[0].Locations[0].Middlewares[0]
c.Assert(m.Id, Equals, cl.Id)
c.Assert(m.Type, Equals, cl.Type)
c.Assert(m.Priority, Equals, cl.Priority)
cl2 := s.makeConnLimit("c1", 10, "client.ip", 3, loc)
out, err = s.client.UpdateMiddleware(registry.GetRegistry().GetSpec(cl.Type), loc.Hostname, loc.Id, cl2)
c.Assert(err, IsNil)
c.Assert(out, NotNil)
c.Assert(out.Id, Equals, cl2.Id)
c.Assert(out.Priority, Equals, cl2.Priority)
status, err := s.client.DeleteMiddleware(registry.GetRegistry().GetSpec(cl.Type), loc.Hostname, loc.Id, cl.Id)
c.Assert(err, IsNil)
c.Assert(status, NotNil)
}
示例13: newVulcandClient
/**
Initialize an etcd API client
*/
func newVulcandClient(vulcandAdminURLString string) (*vulcandAPI.Client, error) {
var u *url.URL
var err error
if u, err = url.Parse(os.ExpandEnv(vulcandAdminURLString)); err != nil {
return nil, fmt.Errorf("Could not parse Vulcand admin URL: %v. Error: %v", vulcandAdminURLString, err)
}
if u.Scheme == "" || u.Host == "" || u.Host == ":" || u.Path != "" {
return nil, fmt.Errorf("Invalid URL provided for Vulcand API server: %v.", u)
}
c := vulcandAPI.NewClient(vulcandAdminURLString, vulcandRegistry.GetRegistry())
if c == nil {
return nil, fmt.Errorf("Could not initialize Vulcand API client")
}
return c, nil
}
示例14: createRouter
func createRouter(prefix string) (router.Router, error) {
vURL, err := config.GetString(prefix + ":api-url")
if err != nil {
return nil, err
}
domain, err := config.GetString(prefix + ":domain")
if err != nil {
return nil, err
}
client := api.NewClient(vURL, registry.GetRegistry())
vRouter := &vulcandRouter{
client: client,
prefix: prefix,
domain: domain,
}
return vRouter, nil
}
示例15: SetUpTest
func (s *EtcdSuite) SetUpTest(c *C) {
// Initiate a backend with a registry
key, err := secret.KeyFromString(s.key)
c.Assert(err, IsNil)
box, err := secret.NewBox(key)
c.Assert(err, IsNil)
engine, err := New(
s.nodes,
s.etcdPrefix,
registry.GetRegistry(),
Options{
EtcdConsistency: s.consistency,
Box: box,
})
c.Assert(err, IsNil)
s.ng = engine.(*ng)
s.client = s.ng.client
// Delete all values under the given prefix
_, err = s.client.Get(s.etcdPrefix, false, false)
if err != nil {
// There's no key like this
if !notFound(err) {
// We haven't expected this error, oops
c.Assert(err, IsNil)
}
} else {
_, err = s.ng.client.Delete(s.etcdPrefix, true)
c.Assert(err, IsNil)
}
s.changesC = make(chan interface{})
s.stopC = make(chan bool)
go s.ng.Subscribe(s.changesC, s.stopC)
s.suite.ChangesC = s.changesC
s.suite.Engine = engine
}