本文整理匯總了Golang中github.com/redhat-cip/skydive/topology/graph.Graph.AddEventListener方法的典型用法代碼示例。如果您正苦於以下問題:Golang Graph.AddEventListener方法的具體用法?Golang Graph.AddEventListener怎麽用?Golang Graph.AddEventListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/redhat-cip/skydive/topology/graph.Graph
的用法示例。
在下文中一共展示了Graph.AddEventListener方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewNeutronMapper
func NewNeutronMapper(g *graph.Graph, authURL string, username string, password string, tenantName string, regionName string) (*NeutronMapper, error) {
mapper := &NeutronMapper{graph: g}
opts := gophercloud.AuthOptions{
IdentityEndpoint: authURL,
Username: username,
Password: password,
TenantName: tenantName,
AllowReauth: true,
}
provider, err := openstack.AuthenticatedClient(opts)
if err != nil {
return nil, err
}
/* TODO(safchain) add config param for the Availability */
client, err := openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{
Name: "neutron",
Region: regionName,
Availability: gophercloud.AvailabilityPublic,
})
if err != nil {
return nil, err
}
mapper.client = client
// Create a cache with a default expiration time of 5 minutes, and which
// purges expired items every 30 seconds
expire := config.GetConfig().GetInt("cache.expire")
cleanup := config.GetConfig().GetInt("cache.cleanup")
mapper.cache = cache.New(time.Duration(expire)*time.Second, time.Duration(cleanup)*time.Second)
mapper.nodeUpdaterChan = make(chan graph.Identifier, 500)
g.AddEventListener(mapper)
return mapper, nil
}