management.tracing.sampling.probability not showing up in my microservices project. I'm using micrometer and webclient. how do i fix this? - micrometer

so, I can use the property management.tracing.sampling.probability in my discovery server. But in my microservices classes i can't see or use the property in my yaml file. I've tried like every dependency possible. but I don't understand how i can only use and see it in my discovery server.

Related

"Dependency hell" when using same npm module for both sdk and service itself

I'm currently developing a project in Node JS that uses microservices architecture, in which each service has it's own repository that contains both the code for the service itself (NodeJS express server), and also an SDK file that I publish for other services to use with methods that are available in this service and Typescript definitions.
So for instance I have a users-service that handles all of the user related actions, and a reports-service that handles all of the reports that users can CRUD.
users-service has a method called "deleteUser" that also goes to reports-service SDK in order to delete all of this user reports. On the other hand reports-service uses user-service SDK to "getUserById" for instance. So what happens is that user-service has reports-service-sdk as one of it's dependencies, and reports-service has users-service-sdk as one of its dependencies. Because the SDK is inside the same npm module with the service, I get users-service-sdk as one of the dependencies of users-service.
I thought of separating the SDK with a different package.json file, but I wanted to know if it's the right way to go or am I doing something really wrong in my architecture :)
Thanks.
This sounds like Circular Dependency which as you stated in the title is tough to deal with. Microservices are great but this sort of architecture sounds like a lot of extra unnecessary work without any added benefit.
You should look into running your services/packages/repositories as Cloud functions (or Firebase functions). AWS also has their own solution for microservices architecture. The reason being is each service can communicate with other services by using internal authorized calls or authorized REST API calls --- or you can make them totally public.
The great thing about these Google Cloud Functions is each function is automatically an Express end-point that accepts GET, POST, DELETE, PUT. Or if you use the internal call for Firebase, each function automatically contains relevant context from the frontend (such as the user's authentication details).
You also configure IAM permissions to only allow who and what service you want to be able to execute your cloud functions so that you have full control of permissions.
To answer your questions directly though, I would definitely avoid Package A having Package B as a dependency as Package B has Package A as a dependency. You absolutely can make that work but there's no upside and a lot of downside.
Here's an old thread which covers the topic.

How to create low code based workflow setup in nodejs?

I want to create a workflow automation where an activity comes in and user can setup a multilevel workflow.
For frontend i am using https://reactflow.dev
How to structure things in nodejs backend. Things like database, accessing control flow statements, statements which requires crons.
You also may want to have a look at node-red.
It's an open-source product that does exactly that.
There's a set of built-in nodes.
You can develop your own nodes, or import 3rd party ones. Which are stored in NPM.
You can also just create a node with javascript or typescript code in it, on the fly.
You should check Flumejs: https://flume.dev/
https://flume.dev/docs/quick-start/
Also you should see this code sandbox example. Try to read the code
and all the dependencies: https://codesandbox.io/s/node-based-code-generation-test-forked-ll9flz?file=/src/App.tsx
I hope you find this helpful.

How to use CouchDB in Sails.js

I want to create a web in node js with the using the "Sails.js" framework and "CouchDB" database. I have check its package and I found lots of package for that.
https://www.npmjs.com/search?q=couchdb
So any one can suggest which package I can used for my application and also want to know for this I need to create a custom adapter.
If there has no requirement of create a custom adapter, so can I use the sails module feature.
The most popular CouchDB adapter in JS :
PouchDB
nanoDB
They are both available on NPM.
PouchDB has a lot of features and his API is easy to use. It also supports a lot of return types (callbacks,promises, async/await). There's also a lot of plugins around PouchDB.
As for nanoDB, it has less features(since it`s minimalist) but it covers all the general features of CouchDB.
Note: nanoDB normal implementation is with callbacks(which can be very ugly). There is an implementation of nanoDB with promises here.
You can take a look also to this adapter sails-couchdb-orm, but it could be no longer maintained. If you plan deploying your project using IBM Bluemix, you should try using sails-cloudant-orm. Cloudant is based on Apache CouchDB.

How to generate node.js API docs using swagger

I have an application developed with Node.js/expressjs. It's working fine. Now I need to generate API document using Swagger. There is a module swagger-node. Do I need to re-write the whole app using this module or is there any other solution to use this module and what is the use of swagger-ui if using swagger-node.
Not from what I can tell. You should be able to generate your swagger project as described, and then just make sure that the information in the yaml file points to the actual controllers and methods that your code uses.
You can create a standalone yaml file that is compliant with Swagger/OpenAPI which can therefore be rendered into Swagger documentation. The Swagger-UI is useful for creating this yaml file. Swagger also offers various tools for testing APIs and generating code -- to use these effectively you will need a method for integrating the controller/model definitions in your yaml file into your existing codebase.
To achieve this integration I typically expose my existing codebase as an api of controller functions -- then import it as a module into the code generated by my documented API. This allows me to trust my API documentation without the burden of porting my whole codebase into Swagger's required directory structure. I believe this is the best currently available approach but is not always worthwhile.

Hapi Swagger skip certain endpoints

Since the npm module hapi-swagger doesn't support file upload endpoints I need a way to skip certain endpoints in my tests.
I've checked the docs and there's no beforeEach or any way to check which endpoint is which during the test runs.
Currently I've just got my environment set to TEST and have an if in the target handler but that's messy and complicated.
Is there any way to skip endpoints?
I am not quite sure of what you are trying to achieve above. The use of tags can create groups of endpoints. Its often used for pre-release or beta groupings. This maybe of use to you.
The latest version of hapi-swagger now also supports basic file uplaods, so you maybe able skip this issue.
Both tags and file uploads are cover in the project readme and code examples of there use can be found in the https://github.com/glennjones/be-more-hapi project.

Resources