Cloud Foundy Services Connector (Node.js)

这个库提供了一个代理的实现,用来开发在 Cloud Foundry 基础平台上的任何定制服务。

示例代码:

Broker = require 'cf-services-connector'

config = require 'config/custom-service' # JSON config file

broker = new Broker(config)

broker.start  (err) ->
    broker.log.error(err)

broker.on 'error', (err) ->
    broker.log.error(err)

broker.on 'provision', (req, next) ->
    # Do custom provisioning action / generate credentials
    # The API allows 'dashboard_url' to be returned here, i.e.:
    # next({dashboard_url: "http://example/instance1" }) 
    next();

broker.on 'unprovision', (req, next) ->
    # Delete service instance
    # req.params.id
    next()

broker.on 'bind', (req, next) ->
    # Take any action for binding
    reply =
        credentials =
            host: '192.168.100.200'
            port: 9999
            user: 'demo'
            pass: 'demo'

    next(credentials)

broker.on 'unbind', (service, cb) ->
    # Undo instance binding
    # here we tell the CC this instance does not exist
    reply =
        doesNotExist: true
    next(reply)

猜你喜欢

转载自blog.csdn.net/phj_88/article/details/81734919