Comments (9)
Published definitions as DefinitelyTyped/DefinitelyTyped#17373
Install with yarn add @types/cote
The utils I mentioned earlier make use of the definitions but are a different thing
May be more useful if your usage of cote
is similar to mine
I adapted examples and published the package as well: https://github.com/makepost/nyan-cote
from cote.
True @dashersw, but you can publish typings for your projects without writing it in typescript.
I see a lot of that now when using vscode. IDE's are smart to work with typings. eg express, node, etc see typings, definatelytyped
from cote.
@robophil exactly! that's what I understood from "typescript support", just adding the typings. cote is written in ES6, and we will never rewrite it in TS.
from cote.
with node supporting es6 a bit more with each release, would that still be necessary?
from cote.
@robophil it would bring in type safety and code completion for TS users and modern IDEs.
@dulichan it's not a priority for me right now, but I would love if someone tackled this problem.
from cote.
Have a look at https://github.com/makepost/microservice-playground
Responder and Requester remind me of Service and Inject from typedi
So I applied decorators, metadata, proxies and async/await to get a similar API
Brings my services type safety and code completion in VS Code
Has Publisher, Requester, Responder and Subscriber
I want to focus on logic and avoid introducing extra names
So it uses names of decorated classes as both key
and name
The latter, name
, is prefixed by e.g. Publisher--
If anyone is interested I can make a npm package
from cote.
from cote.
Hello @makepost, thanks for the immense effort! This is a nice beginning, and I would have loved if we worked together on this — the typings have some errors and shortcomings and now since they are in DefinitelyTyped, they are kind of the go-to typings.
Here are some of my initial observations:
- There should be no rigid definition of a
cote.Action
other than the requirement that it's an object (record types in JSDoc) with atype
property. It's not an internal class and shouldn't be called as if so. Advertisement
differs from type to type,subscribesTo
shouldn't be an option for a responder.- There are about 10 other
discoveryOptions
and now they are hidden. - The classes actually inherit from
EventEmitter2
and therefore also expose its API. - There are missing classes:
TimeBalancedRequester
andPendingBalancedRequester
. - As you've mentioned this only takes into account Promises, but the API also works with callbacks.
- There are certain pre-built events that the user can listen to on every component, like
cote:added
andcote:removed
.
Finally, about nyan-cote: key
's can't be automatically deduced from class names, because if a Requester
and a Responder
have different keys, they won't be able to communicate.
from cote.
Thanks for the feedback
@types/cote
has just updated
I addressed all the issues you mentioned
How do I improve nyan-cote
?
Example services follow cote
README and are able to communicate
For Responder
, the key is its own class name
For Requester
, the key is the class name of the Responder
it talks to
from cote.
Related Issues (20)
- No namespace and a strange "type" for Requester and Responder instances HOT 7
- Subscriber binding a socket instead of connecting (client vs server) ?
- Round-robin mechanism leads to lost requests HOT 4
- Client lost data when service graceful shutdown
- cote.js actively maintained? HOT 2
- Support specific ip addresses of instances. HOT 8
- Using cotejs on k3s cluster HOT 2
- K3S Kubernetes Cluster: TypeError [ERR_INVALID_ARG_TYPE]: The "options.port" property must be one of type number or string. Received null HOT 8
- Invalid 'main' field - node-discover HOT 2
- hiredis dependency preventing using node versions > 10? HOT 3
- [QUESTION] Are broadcasts mandatory? HOT 3
- Remove hiredis dependency HOT 2
- Discovery not working HOT 2
- How can I allow anyone over the Internet to run replicas of a service? HOT 1
- Cote not working with AWS Autoscalling instances. HOT 3
- Select port used
- Can't start cote due to port issue HOT 2
- View IP address of incoming request/broadcast HOT 1
- Hide "no listeners found for event" log HOT 2
- Requester can see the Responder but dont send request to it HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cote.