-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(natss,nats): add natss test, throw error on nats init
- Loading branch information
Showing
4 changed files
with
36 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,6 @@ | ||
const highland = require('highland') | ||
const lodash = require('lodash') | ||
const Natss = require('nats-transport') | ||
|
||
module.exports = async config => { | ||
const publishers = new Map() | ||
const subscribers = new Map() | ||
const transport = await Natss(config) | ||
// const sub = transport.subscribe('test') | ||
// sub.resume() | ||
// const pub = transport.publish('test') | ||
|
||
function publish(service, channel) { | ||
const id = [service, channel].join('.') | ||
if (publishers.has(id)) return publishers.get(id) | ||
const pub = transport.publish(id) | ||
publishers.set(id, pub) | ||
|
||
return pub | ||
|
||
// stream | ||
// .map(x=>{ | ||
// x.service = service | ||
// return x | ||
// }) | ||
// // .doto(x=>{ | ||
// // console.log('publishing',x) | ||
// // }) | ||
// .pipe(pub) | ||
|
||
// return stream | ||
} | ||
|
||
function subscribe(service, channel) { | ||
const id = [service, channel].join('.') | ||
const sub = transport.subscribe(id) | ||
if (subscribers.has(id)) return subscribers.get(id).observe() | ||
subscribers.set(id, sub) | ||
return sub | ||
} | ||
|
||
// function publish(service,channel){ | ||
// const id = [service,channel].join('.') | ||
// console.log('natss publisher transport',id) | ||
// if(publishers.has(id)) return publishers.get(id) | ||
// const pub = transport.publish(id) | ||
// publishers.set(id,pub) | ||
// return pub | ||
// } | ||
|
||
// function subscribe(service,channel){ | ||
// const id = [service,channel].join('.') | ||
// console.log('natss susbscribe transport',id) | ||
// if(subscribers.has(id)) return subscribers.get(id) | ||
// const sub = transport.subscribe(id) | ||
// sub.resume() | ||
// subscribers.set(id,sub) | ||
// return sub | ||
// } | ||
|
||
return { | ||
publish, | ||
subscribe, | ||
} | ||
throw new Error('Nats transport not implemented') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters