-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
push origin masterMerge branch 'alexkvak-feature/touch-and-get-tags-i…
…f-needed'
- Loading branch information
Showing
33 changed files
with
217 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"plugins": ["@typescript-eslint"], | ||
"extends": [ | ||
"prettier", | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"overrides": [ | ||
{ | ||
"files": ["src/**/__mocks__/*.ts", "*.spec.ts"], | ||
"rules": { | ||
"@typescript-eslint/no-explicit-any": "off" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
import { executorReturnsUndefinedError } from "./errors/errors"; | ||
import { ReadWriteOptions } from "./storage/Storage"; | ||
import { Record } from "./storage/Record"; | ||
|
||
export interface ExecutorContext { | ||
export interface ExecutorContext<R> { | ||
key: string; | ||
executor: Executor; | ||
options: ReadWriteOptions; | ||
record?: Record; | ||
executor: Executor<R>; | ||
options: ReadWriteOptions<R>; | ||
record?: Record<R>; | ||
} | ||
|
||
export type ValueOfExecutor<V extends Executor> = ReturnType<V> extends Promise<infer RT> ? RT : V; | ||
export type Executor = (...args: any[]) => Promise<any> | any; | ||
export async function runExecutor<R>(executor: Executor<R>): Promise<R> { | ||
const result = await executor(); | ||
|
||
if (result === undefined) { | ||
throw executorReturnsUndefinedError(); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
export type Executor<R> = (...args: unknown[]) => Promise<R> | R; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { Executor, ValueOfExecutor } from "./Executor"; | ||
import { Executor } from "./Executor"; | ||
import { WriteOptions, ReadWriteOptions } from "./storage/Storage"; | ||
import {RecordValue} from "./storage/Record"; | ||
import { Record } from "./storage/Record"; | ||
|
||
/** | ||
* Manager is the basic interface for all caching classes. Manager must implement | ||
* two simple methods - get, and set. Cache class will delegate it's get and set calls to manager | ||
* which must decide what record should be threaten as invalid, when and how to update record | ||
*/ | ||
export interface Manager { | ||
get<E extends Executor>(key: string, executor: E, options: ReadWriteOptions): Promise<ValueOfExecutor<E>>; | ||
set(key: string, value: RecordValue, options?: WriteOptions): Promise<any>; | ||
get<R>(key: string, executor: Executor<R>, options: ReadWriteOptions<R>): Promise<R>; | ||
set<R>(key: string, value: R, options?: WriteOptions<R>): Promise<Record<R>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.