Cloud Foundy Services Connector (Node.js)基于 Cloud Foundry 平台开发定制服务

联合创作 · 2023-10-01

这个库提供了一个代理的实现,用来开发在 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)
浏览 1
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报