import { ListWatch } from './cache' ; import { KubeConfig } from './config' ; import { KubernetesListObject , KubernetesObject } from './types' ; import { Watch } from './watch' ; import http = require ( 'http' ) ; export type ObjectCallback < T extends KubernetesObject > = ( obj : T ) => void ; export type ErrorCallback = ( err ? : any ) => void ; export type ListCallback < T extends KubernetesObject > = ( list : T [ ] , ResourceVersion : string ) => void ; export type ListPromise < T extends KubernetesObject > = ( ) => Promise < { response : http . IncomingMessage ; body : KubernetesListObject < T > ; } > ; export const ADD = 'add' ; export const UPDATE = 'update' ; export const CHANGE = 'change' ; export const DELETE = 'delete' ; export const CONNECT = 'connect' ; export const ERROR = 'error' ; export interface Informer < T > { on ( verb , fn ) : void ; off ( verb , fn ) : void ; start ( ) : Promise < void > ; stop ( ) : Promise < void > ; } export function makeInformer < T > ( kubeconfig , path , listPromiseFn , labelSelector ? ) { const watch = new Watch ( kubeconfig ) ; return new ListWatch < T > ( path , watch , listPromiseFn , false , labelSelector ) ; }