本文整理匯總了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
}