當前位置: 首頁>>代碼示例>>Golang>>正文


Golang plugins.Handle函數代碼示例

本文整理匯總了Golang中github.com/docker/docker/pkg/plugins.Handle函數的典型用法代碼示例。如果您正苦於以下問題:Golang Handle函數的具體用法?Golang Handle怎麽用?Golang Handle使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Handle函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Handle

// Handle sets a callback for a given capability. The callback will be called for every plugin with a given capability.
// TODO: append instead of set?
func Handle(capability string, callback func(string, *plugins.Client)) {
	pluginType := fmt.Sprintf("docker.%s/1", strings.ToLower(capability))
	manager.handlers[pluginType] = callback
	if manager.handleLegacy {
		plugins.Handle(capability, callback)
	}
}
開發者ID:ilkka,項目名稱:docker,代碼行數:9,代碼來源:manager.go

示例2: Init

// Init makes sure a remote driver is registered when a network driver
// plugin is activated.
func Init(dc driverapi.DriverCallback) error {
	plugins.Handle(driverapi.NetworkPluginEndpointType, func(name string, client *plugins.Client) {
		if err := dc.RegisterDriver(name, newDriver(name, client)); err != nil {
			log.Errorf("error registering driver for %s due to %v", name, err)
		}
	})
	return nil
}
開發者ID:fwalker,項目名稱:dashboard,代碼行數:10,代碼來源:driver.go

示例3: Init

// Init registers a remote ipam when its plugin is activated
func Init(cb ipamapi.Callback, l, g interface{}) error {
	plugins.Handle(ipamapi.PluginEndpointType, func(name string, client *plugins.Client) {
		if err := cb.RegisterIpamDriver(name, newAllocator(name, client)); err != nil {
			log.Errorf("error registering remote ipam %s due to %v", name, err)
		}
	})
	return nil
}
開發者ID:previousnext,項目名稱:kube-ingress,代碼行數:9,代碼來源:remote.go

示例4: Handle

// Handle sets a callback for a given capability. It is only used by network
// and ipam drivers during plugin registration. The callback registers the
// driver with the subsystem (network, ipam).
func Handle(capability string, callback func(string, *plugins.Client)) {
	pluginType := fmt.Sprintf("docker.%s/1", strings.ToLower(capability))

	// Register callback with new plugin model.
	store.handlers[pluginType] = callback

	// Register callback with legacy plugin model.
	if allowV1PluginsFallback {
		plugins.Handle(capability, callback)
	}
}
開發者ID:alexmavr,項目名稱:docker,代碼行數:14,代碼來源:store.go

示例5: Init

// Init makes sure a remote driver is registered when a network driver
// plugin is activated.
func Init(dc driverapi.DriverCallback) error {
	plugins.Handle(driverapi.NetworkPluginEndpointType, func(name string, client *plugins.Client) {
		c := driverapi.Capability{
			DataScope: datastore.GlobalScope,
		}
		if err := dc.RegisterDriver(name, newDriver(name, client), c); err != nil {
			log.Errorf("error registering driver for %s due to %v", name, err)
		}
	})
	return nil
}
開發者ID:wcwxyz,項目名稱:libnetwork,代碼行數:13,代碼來源:driver.go

示例6: Init

// Init does the necessary work to register remote drivers
func Init(dc driverapi.DriverCallback) error {
	plugins.Handle(driverapi.NetworkPluginEndpointType, func(name string, client *plugins.Client) {

		// TODO : Handhake with the Remote Plugin goes here

		newDriver := &driver{networkType: name, endpoint: client}
		if err := dc.RegisterDriver(name, newDriver); err != nil {
			log.Errorf("Error registering Driver for %s due to %v", name, err)
		}
	})
	return nil
}
開發者ID:choldrim,項目名稱:docker,代碼行數:13,代碼來源:driver.go

示例7: Init

// Init makes sure a remote driver is registered when a network driver
// plugin is activated.
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
	plugins.Handle(driverapi.NetworkPluginEndpointType, func(name string, client *plugins.Client) {
		// negotiate driver capability with client
		d := newDriver(name, client)
		c, err := d.(*driver).getCapabilities()
		if err != nil {
			log.Errorf("error getting capability for %s due to %v", name, err)
			return
		}
		if err = dc.RegisterDriver(name, d, *c); err != nil {
			log.Errorf("error registering driver for %s due to %v", name, err)
		}
	})
	return nil
}
開發者ID:CadeLaRen,項目名稱:docker-3,代碼行數:17,代碼來源:driver.go

示例8: Init

// Init registers a remote ipam when its plugin is activated
func Init(cb ipamapi.Callback, l, g interface{}) error {
	plugins.Handle(ipamapi.PluginEndpointType, func(name string, client *plugins.Client) {
		a := newAllocator(name, client)
		if cps, err := a.(*allocator).getCapabilities(); err == nil {
			if err := cb.RegisterIpamDriverWithCapabilities(name, a, cps); err != nil {
				log.Errorf("error registering remote ipam driver %s due to %v", name, err)
			}
		} else {
			log.Infof("remote ipam driver %s does not support capabilities", name)
			log.Debug(err)
			if err := cb.RegisterIpamDriver(name, a); err != nil {
				log.Errorf("error registering remote ipam driver %s due to %v", name, err)
			}
		}
	})
	return nil
}
開發者ID:CadeLaRen,項目名稱:docker-3,代碼行數:18,代碼來源:remote.go

示例9: Handle

// Handle sets a callback for a given capability. It is only used by network
// and ipam drivers during plugin registration. The callback registers the
// driver with the subsystem (network, ipam).
func (ps *Store) Handle(capability string, callback func(string, *plugins.Client)) {
	pluginType := fmt.Sprintf("docker.%s/%s", strings.ToLower(capability), defaultAPIVersion)

	// Register callback with new plugin model.
	ps.Lock()
	handlers, ok := ps.handlers[pluginType]
	if !ok {
		handlers = []func(string, *plugins.Client){}
	}
	handlers = append(handlers, callback)
	ps.handlers[pluginType] = handlers
	ps.Unlock()

	// Register callback with legacy plugin model.
	if allowV1PluginsFallback {
		plugins.Handle(capability, callback)
	}
}
開發者ID:thinkingo,項目名稱:docker,代碼行數:21,代碼來源:store.go

示例10: Handle

// Handle sets a callback for a given capability. It is only used by network
// and ipam drivers during plugin registration. The callback registers the
// driver with the subsystem (network, ipam).
func (ps *Store) Handle(capability string, callback func(string, *plugins.Client)) {
	plugins.Handle(capability, callback)
}
開發者ID:SUSE,項目名稱:docker.mirror,代碼行數:6,代碼來源:store.go


注:本文中的github.com/docker/docker/pkg/plugins.Handle函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。