added types for eureka-js-client

This commit is contained in:
Ilko Hoffmann
2017-04-07 17:05:10 +02:00
parent 374e200f7c
commit 094e41b9ce
3 changed files with 123 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import { Eureka } from 'eureka-js-client';
// example configuration
let client = new Eureka({
// application instance information
instance: {
app: 'jqservice',
hostName: 'localhost',
ipAddr: '127.0.0.1',
port: 8080,
vipAddress: 'jq.test.something.com',
dataCenterInfo: {
name: 'MyOwn',
},
},
eureka: {
// eureka server host / port
host: '192.168.99.100',
port: 32768,
}
});

80
types/eureka-js-client/index.d.ts vendored Normal file
View File

@@ -0,0 +1,80 @@
// Type definitions for eureka-js-client 4.3.0
// Project: https://github.com/jquatier/eureka-js-client
// Definitions by: Ilko Hoffmann <https://github.com/Schnillz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export declare class Eureka {
constructor(config: EurekaClient.EurekaConfig)
start(): void;
stop(): void;
getInstancesByAppId(appId: string): Array<string>;
getInstancesByVipAddress(vidAddress: string): Array<string>;
}
declare namespace EurekaClient {
type InstanceStatus = 'UP' | 'DOWN' | 'STARTING' | 'OUT_OF_SERVICE' | 'UNKNOWN';
type ActionType = 'ADDED' | 'MODIFIED' | 'DELETED';
interface EurekaConfig {
instance: EurekaInstanceConfig,
eureka: EurekaClientConfig
}
interface EurekaInstanceConfig {
app: string,
hostName: string,
ipAddr: string,
vipAddress: string,
dataCenterInfo: DataCenterInfo,
port?: number,
instanceId?: string,
appGroupName?: string,
sid?: string,
securePort?: PortWrapper,
homePageUrl?: string,
statusPageUrl?: string,
healthCheckUrl?: string,
secureHealthCheckUrl?: string,
secureVipAddress?: string,
countryId?: number,
status?: InstanceStatus,
overriddenstatus?: InstanceStatus,
leaseInfo?: LeaseInfo,
isCoordinatingDiscoveryServer?: boolean,
metadata?: Array<[string, string]>,
lastUpdatedTimestamp?: number,
lastDirtyTimestamp?: number,
actionType?: ActionType,
asgName?: string
}
interface EurekaClientConfig {
host: string,
port: number,
heartbeatInterval?: number,
registryFetchInterval?: number,
maxRetries?: number,
requestRetryDelay?: number,
fetchRegistry?: boolean,
filterUpInstances?: boolean,
servicePath?: string,
ssl?: boolean,
useDns?: boolean,
preferSameZone?: boolean,
clusterRefreshInterval?: boolean,
fetchMetadata?: boolean,
registerWithEureka?: boolean,
useLocalMetadata?: boolean,
preferIpAddress?: boolean
}
interface PortWrapper {
enabled: boolean,
port: number
}
interface LeaseInfo {
renewalIntervalInSecs: number;
durationInSecs: number;
}
interface DataCenterInfo {
name: 'Netflix' | 'Amazon' | 'MyOwn';
}
}

View File

@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"eureka-js-client-tests.ts"
]
}