npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

myklorejs

v0.0.1

Published

Orquestador de microservicios con retry inteligente, circuit breakers y aprendizaje de patrones de fallo.

Readme

MykloreJS: Orquestador de Microservicios

MykloreJS es una librería robusta y flexible diseñada para simplificar la comunicación y gestión de microservicios. Proporciona un sistema automatizado para manejar la interacción entre servicios, incorporando patrones de resiliencia como reintentos inteligentes y Circuit Breakers, además de un módulo de aprendizaje que optimiza las rutas de comunicación basándose en patrones de fallo.

Características Principales

  • Comunicación Automatizada: Gestiona la comunicación entre tus microservicios de manera eficiente y transparente.
  • Retry Inteligente: Reintenta automáticamente las operaciones fallidas con una estrategia de retroceso exponencial, mejorando la robustez del sistema.
  • Circuit Breaker: Implementa el patrón Circuit Breaker para prevenir cascadas de fallos, aislando servicios problemáticos y permitiendo su recuperación controlada.
  • Aprendizaje de Patrones de Fallo: Un módulo inteligente que aprende de los fallos pasados para optimizar futuras rutas de comunicación y anticipar problemas.
  • Fácil Integración: Diseñado para ser fácilmente integrable en proyectos basados en Node.js y TypeScript.

Instalación

Para instalar MykloreJS en tu proyecto, utiliza npm:

npm install myklorejs

Uso

Inicialización del Orquestador

import { ServiceOrchestrator } from 'myklorejs';

const orchestrator = new ServiceOrchestrator();

Llamada a un Servicio

Utiliza el método callService para invocar tus microservicios. MykloreJS se encargará automáticamente de los reintentos y la lógica del Circuit Breaker.

async function callMyService() {
  const serviceName = 'userService';
  const endpoint = '/users/123';
  const data = { userId: '123' };

  try {
    const response = await orchestrator.callService(serviceName, endpoint, data);
    console.log(`Respuesta del servicio ${serviceName}:`, response);
  } catch (error) {
    console.error(`Error al llamar al servicio ${serviceName}:`, error.message);
  }
}

callMyService();

Configuración Personalizada (Opcional)

Puedes personalizar el comportamiento del Circuit Breaker y el Retry al inicializar el ServiceOrchestrator o directamente en los módulos si los importas de forma individual.

import { ServiceOrchestrator, CircuitBreakerModule, RetryModule } from 'myklorejs';

// Configuración del Circuit Breaker
const customCircuitBreaker = new CircuitBreakerModule({
  failureThreshold: 5,   // Número de fallos antes de abrir el circuito
  resetTimeout: 10000, // Tiempo en ms para pasar a HALF_OPEN
  successThreshold: 3  // Número de éxitos en HALF_OPEN para cerrar el circuito
});

// Configuración del Retry
const customRetryModule = new RetryModule(orchestrator.communicationModule); // Necesita una instancia de CommunicationModule

// Puedes inyectar tus módulos personalizados si es necesario
// const customOrchestrator = new ServiceOrchestrator(customCircuitBreaker, customRetryModule, ...);

Estructura del Proyecto

El proyecto sigue una estructura modular, facilitando la comprensión y extensión:

myklorejs/
├── src/
│   ├── communicationModule.ts      # Manejo de la comunicación básica entre servicios
│   ├── retryModule.ts              # Lógica de reintentos inteligentes
│   ├── circuitBreakerModule.ts     # Implementación del patrón Circuit Breaker
│   ├── failureLearningModule.ts    # Módulo para aprender de patrones de fallo
│   ├── serviceOrchestrator.ts      # El orquestador principal que integra los módulos
│   └── index.ts                    # Archivo de exportación principal de la librería
├── dist/                           # Salida de la compilación de TypeScript
├── tests/                          # Pruebas unitarias e de integración
├── package.json
├── tsconfig.json
├── .eslintrc.js
├── .prettierrc.js
└── README.md

Contribución

¡Agradecemos cualquier contribución! Si encuentras un error o tienes una sugerencia de mejora, no dudes en abrir un issue o enviar un pull request.

Licencia

Este proyecto está bajo la licencia MIT. Consulta el archivo LICENSE para más detalles.