1.1.1 • Published 8 years ago
@eyecone/blastmedia-service v1.1.1
Service
Module
Allows to connect to the shared configuration and expose methods though various gateways.
Services
A service (when used with this module) is a node instance (or multiple instances) dedicated to perform tasks related to a defined domain.
eg. Image processing, Video processing, Customer data, Presentational tasks
A service can be splitted into multiple services if it handles too many tasks.
Service class:
Methods:
- constructor(serviceName, opts)
- opts:
- hostname:
String
(service1.domain.com) - port:
Int
(3003) - publicUrl:
String
(nwsr.eu)
- hostname:
- opts:
- toJSON(): return an
Object
with name, hostname, port, uptime (in seconds) - setPublicUrl()
- setDefaultHTTPBanner(path)
- path: String (default to
/_banner
)
- path: String (default to
- useGateway(Gateway)
- Gateway:
Gateway
extended object
- Gateway:
- register([hostname[, port, infos]])
- hostname:
String
(default to constructor arg) - port:
Int
(default to constructor arg) - infos:
Object
(default to constructor created serviceInfos)
- hostname:
- start([hostname[, port, serviceInfos]])
- Starts the gatway and call
register()
with specified args.
- Starts the gatway and call
Properties:
- gateway: returns the
Gateway
object. - config:
Object
- hostname
- port
- serviceInfos
- registry: returns the
Registry
object (likely to be the Etcd wrapper) - hostname: returns config.hostname
- port: returns config.port
- serviceInfos: returns config.serviceInfos
- uptime
- static HTTP_GATEWAY: returns the
HTTPGateway
class (extendsGateway
)
Exports:
Service
RemoteService
RemoteService class:
This class dynamically generate methods based upon the methods exposed by the remote service.
// @TODO: Write doc about this black magic stuff.
Gateways
A gateway is a way to connect to the service. A service can have multiple gateways.
Gateways available:
- HTTP
- Uses Express express internally.
- gRPC (not yet implemented)
- Uses gRPC to provide a gateway using HTTP/2.
Registry
// @TODO: Write doc about this awesome stuff.