digital-samba-mcp-server
Version:
Digital Samba MCP Server - Model Context Protocol server for Digital Samba's video conferencing API
211 lines • 6.21 kB
TypeScript
/**
* Digital Samba API Client with Graceful Degradation Integration
*
* This module integrates the graceful degradation pattern with the Digital Samba API client
* and circuit breaker for comprehensive resilience strategies.
*
* Key features:
* - Combines circuit breaker pattern with graceful degradation strategies
* - Provides fallback mechanisms for API operations during outages
* - Implements cache-based fallbacks for degraded service
* - Features intelligent retry mechanisms with exponential backoff
* - Includes health monitoring and metrics integration
*
* @module digital-samba-api-resilient
* @author Digital Samba Team
* @version 0.1.0
*/
import { DigitalSambaApiClient, ApiResponse, PaginationParams, Room, RoomCreateSettings, TokenResponse } from './digital-samba-api.js';
import { MemoryCache } from './cache.js';
import { FallbackConfig, ServiceHealthStatus } from './graceful-degradation.js';
/**
* Resilient API client options
*/
export interface ResilientApiClientOptions {
/**
* Circuit breaker options
*/
circuitBreaker?: {
/**
* Prefix for circuit breaker names
* @default 'api'
*/
circuitPrefix?: string;
/**
* Failure threshold for circuit breaker
* @default 3
*/
failureThreshold?: number;
/**
* Reset timeout for circuit breaker (ms)
* @default 30000
*/
resetTimeout?: number;
/**
* Success threshold for circuit breaker
* @default 2
*/
successThreshold?: number;
/**
* Request timeout for circuit breaker (ms)
* @default 10000
*/
requestTimeout?: number;
/**
* Initial request timeout for circuit breaker (ms)
* @default 30000
*/
initialRequestTimeout?: number;
};
/**
* Graceful degradation options
*/
gracefulDegradation?: {
/**
* Maximum number of retry attempts
* @default 3
*/
maxRetryAttempts?: number;
/**
* Initial retry delay (ms)
* @default 1000
*/
initialRetryDelay?: number;
/**
* Retry backoff factor
* @default 2
*/
retryBackoffFactor?: number;
/**
* Maximum retry delay (ms)
* @default 30000
*/
maxRetryDelay?: number;
};
/**
* Specify fallbacks for specific operations
*/
fallbacks?: {
/**
* Fallback for listRooms operation
*/
listRooms?: FallbackConfig<ApiResponse<Room>>;
/**
* Fallback for getRoom operation
*/
getRoom?: FallbackConfig<Room>;
/**
* Add other operation fallbacks as needed
*/
[key: string]: FallbackConfig<any> | undefined;
};
/**
* Cache instance
*/
cache?: MemoryCache;
}
/**
* Digital Samba API client with resilience patterns
*
* This class combines the circuit breaker and graceful degradation patterns
* to provide comprehensive resilience for the Digital Samba API client.
*/
export declare class ResilientApiClient {
private circuitBreakerClient;
private cache?;
private readonly options;
/**
* Creates a new resilient API client
*
* @param apiClient The Digital Samba API client to wrap
* @param options Configuration options
*/
constructor(apiClient: DigitalSambaApiClient, options?: ResilientApiClientOptions);
/**
* Register fallbacks for operations
*
* @private
* @param fallbacks Fallback configurations
*/
private registerFallbacks;
/**
* List all rooms with resilience
*
* @param params Pagination parameters
* @returns Rooms response
*/
listRooms(params?: PaginationParams): Promise<ApiResponse<Room>>;
/**
* Get a specific room with resilience
*
* @param roomId Room ID
* @returns Room details
*/
getRoom(roomId: string): Promise<Room>;
/**
* Create a new room with resilience
*
* @param settings Room creation settings
* @returns Created room
*/
createRoom(settings: RoomCreateSettings): Promise<Room>;
/**
* Update an existing room with resilience
*
* @param roomId Room ID
* @param settings Room update settings
* @returns Updated room
*/
updateRoom(roomId: string, settings: Partial<RoomCreateSettings>): Promise<Room>;
/**
* Delete a room with resilience
*
* @param roomId Room ID
* @param options Delete options
*/
deleteRoom(roomId: string, options?: {
delete_resources?: boolean;
}): Promise<void>;
/**
* Generate a room token with resilience
*
* @param roomId Room ID
* @param options Token options
* @returns Token response
*/
generateRoomToken(roomId: string, options: any): Promise<TokenResponse>;
/**
* Get system health status
*
* @returns System health status
*/
getSystemHealth(): {
overall: ServiceHealthStatus;
components: {
name: string;
status: ServiceHealthStatus;
lastCheck: Date;
errorCount: number;
message?: string;
}[];
};
/**
* Create a resilient API client from a standard Digital Samba API client
*
* @param apiClient Digital Samba API client
* @param options Resilient API client options
* @returns A new resilient API client
*/
static withResilience(apiClient: DigitalSambaApiClient, options?: ResilientApiClientOptions): ResilientApiClient;
/**
* Create a new resilient API client with the given API key
*
* @param apiKey API key
* @param apiBaseUrl API base URL
* @param options Resilient API client options
* @returns A new resilient API client
*/
static createWithApiKey(apiKey: string, apiBaseUrl?: string, options?: ResilientApiClientOptions): ResilientApiClient;
}
export default ResilientApiClient;
//# sourceMappingURL=digital-samba-api-resilient.d.ts.map