import * as Either from 'fp-ts/lib/Either' ; import * as TaskEither from 'fp-ts/lib/TaskEither' ; import { ElasticsearchClient } from '../../../elasticsearch' ; import { catchRetryableEsClientErrors , RetryableEsClientError , } from './catch_retryable_es_client_errors' ; internal export interface OpenPitResponse { pitId : string ; } internal export interface OpenPitParams { client : ElasticsearchClient ; index : string ; } export const pitKeepAlive = '10m' ; export const openPit = ( { client , index , } ) : TaskEither . TaskEither < RetryableEsClientError , OpenPitResponse > => ( ) => { return client . openPointInTime ( { index , keep_alive : pitKeepAlive , } ) . then ( ( response ) => Either . right ( { pitId : response . body . id } ) ) . catch ( catchRetryableEsClientErrors ) ; } ;