本文整理汇总了Golang中github.com/cloudfoundry/gorouter/config.Config.PruneStaleDropletsInterval方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.PruneStaleDropletsInterval方法的具体用法?Golang Config.PruneStaleDropletsInterval怎么用?Golang Config.PruneStaleDropletsInterval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/gorouter/config.Config
的用法示例。
在下文中一共展示了Config.PruneStaleDropletsInterval方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
"github.com/cloudfoundry/yagnats/fakeyagnats"
"encoding/json"
"time"
)
var _ = Describe("RouteRegistry", func() {
var r *RouteRegistry
var messageBus *fakeyagnats.FakeYagnats
var fooEndpoint, barEndpoint, bar2Endpoint *route.Endpoint
var configObj *config.Config
BeforeEach(func() {
configObj = config.DefaultConfig()
configObj.PruneStaleDropletsInterval = 50 * time.Millisecond
configObj.DropletStaleThreshold = 10 * time.Millisecond
messageBus = fakeyagnats.New()
r = NewRouteRegistry(configObj, messageBus)
fooEndpoint = route.NewEndpoint("12345", "192.168.1.1", 1234,
"id1", map[string]string{
"runtime": "ruby18",
"framework": "sinatra",
})
barEndpoint = route.NewEndpoint("54321", "192.168.1.2", 4321,
"id2", map[string]string{
"runtime": "javascript",
"framework": "node",
})
示例2:
client *fake_routing_api.FakeClient
token *schema.Token
response []db.Route
process ifrit.Process
eventChannel chan routing_api.Event
errorChannel chan error
clock *fakeclock.FakeClock
)
BeforeEach(func() {
logger = lagertest.NewTestLogger("test")
cfg = config.DefaultConfig()
cfg.PruneStaleDropletsInterval = 2 * time.Second
retryInterval := 0
uaaClient = &testUaaClient.FakeClient{}
registry = &testRegistry.FakeRegistryInterface{}
token = &schema.Token{
AccessToken: "access_token",
ExpiresIn: 5,
}
client = &fake_routing_api.FakeClient{}
eventChannel = make(chan routing_api.Event)
errorChannel = make(chan error)
eventSource := fake_routing_api.FakeEventSource{}
client.SubscribeToEventsWithMaxRetriesReturns(&eventSource, nil)
示例3:
Context("When the token fetcher returns an error", func() {
BeforeEach(func() {
tokenFetcher.FetchTokenReturns(nil, errors.New("token fetcher error"))
})
It("returns an error", func() {
err := fetcher.FetchRoutes()
Expect(err).To(HaveOccurred())
Expect(registry.RegisterCallCount()).To(Equal(0))
})
})
})
Describe(".StartFetchCycle", func() {
BeforeEach(func() {
cfg.PruneStaleDropletsInterval = 10 * time.Millisecond
fetcher = NewRouteFetcher(logger, tokenFetcher, registry, cfg, client, retryInterval)
tokenFetcher.FetchTokenReturns(token, nil)
client.RoutesReturns(response, nil)
})
It("periodically fetches routes", func() {
received := make(chan struct{})
client.RoutesStub = func() ([]db.Route, error) {
received <- struct{}{}
return []db.Route{}, nil
}