hydra-router
hydra-router copied to clipboard
A service aware router for Hydra Services
Please help me how to re route service. I am running three local redis instance on port 5353, 5352, 5351 if i am stopping port 5353 and if i am going to use port localhost:5353/v1/router/version it should re route to port 5352 or 5351. Is it correct but this is not working if i am wrong, please explain me how to achieve hydra-router routing feature. Please any one help me.
Is their any other link with examples of hydra-router. Please let me know if it is present.
@PraveenShrivastava11jan when you say that you're running three local redis instance on port 5353, 5352, 5351
are you saying that you have three instances of Redis running? Or do you mean hydra-router
. I would guess "yes" based on the title of your post.
You only need one hydra-router running - locally. In production, you can run several instances behind nginx or a load-balancer for high availability. Can you explain why you're trying to run multiple instances?
On a side note, have you considered joining our hydra-npm slack group where there are people to help answer questions? https://github.com/flywheelsports/hydra#join-us-on-slack
Additionally, I'd be happy to setup a conference call to help answer your questions.
@cjus Thanks for reply. First i am trying with one port i.e 5353 what i am trying to do is i am running one local redis instance and one remote redis instance. so when i am starting my app with local redis instance and between running my service i am stopping my local redis server, so when i request any api call should re route to remote redis instance but it is not happening. Sorry if i am wrong to understand,please help me out how to achieve this features of service routing.
Hello @cjus , I am trying to read all document for hydra-router. Introduction section for hydra-router it is written "Using HydraRouter external clients can connect to services without knowing their IP or port information. HydraRouter takes care of service discovery and routing". Please share some advice how to do this or please explain me how hydra-route takes care of routing service. I was trying to do this from past two days. but i am not able to understand how it is happening. Please let me know were i will get routing service examples.
Thanks.
@PraveenShrivastava11jan Hydra routing (without knowledge of IP/PORT) is accomplished with the use of a shared Redis server. All Hydra-enabled services (that is services which import the hydra or hydra-express NPM module) expect to connect to the same shared Redis server. This is why each service's configuration (./config/config.json) contains an object branch called 'hydra'. That's where the location of the shared Redis server is specified.
So each running service has its underlying hydra module which writes information into Redis. In that way, any hydra-service can look at the information of any other service.
More information about routing and discovery can be found here: https://www.hydramicroservice.com/docs/hydra-core/service-discovery.html
Hydra-Router is (at its core) a Hydra-enabled service - just one that focuses on HTTP and Message routing. Hydra router uses the information stored in the shared Redis service to obtain presence and routing information. Without hydra-router, hydra-enabled services can use the hydra makeAPIRequest
, sendMessage
, or getServicePresence
calls, see more here: https://www.hydramicroservice.com/docs/hydra-core/hydra-methods.html
Hello @cjus,
Thnak you for helping.
Hello @cjus, I have one more doubt, please help me in this also. If i have two same service-name one is running in local redis-server instance and another running in remote redis-server instance and at a time i started running my hydra-router service using local redis-server and when i am browsing using my ip and port for example 192.168.99.100/5353 inside docker container i am able to view hydra-router dashboard, but when i am stopping my local-redis server and i am trying to access the url 192.168.99.100/5353 it should redirect to remote redis-server.
Is it right or wrong, i can able to access my remote redis-server according to routing concept is it correct or wrong, Please explain me what i am trying to do is correct or not.
@PraveenShrivastava11jan Hydra services are bound to a Redis server (or redis cluster). Services using one redis instance can't communicate with services running using other redis servers. You can have services running in containers and on your machine speak to one another if they share the same redis server.
@PraveenShrivastava11jan is there still an outstanding issue/concern here? Or can I close this one?
Hello @cjus i have some more issue related to this please let me give some time to do some research and ask my doubt then you can close this issue.
@PraveenShrivastava11jan thanks for your efforts.