-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the hashed inputs as cache key to allow multiple steps at the sam…
…e time
- Loading branch information
1 parent
90b6672
commit 7b84952
Showing
3 changed files
with
60 additions
and
27 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
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,9 +1,17 @@ | ||
import * as crypto from 'crypto'; | ||
import {IState} from '../interfaces/state/state'; | ||
import {State} from '../classes/state/state'; | ||
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options'; | ||
import {StateCacheStorage} from '../classes/state/state-cache-storage'; | ||
|
||
function sha256(message: string): string { | ||
const hash = crypto.createHash('sha256'); | ||
hash.update(message); | ||
return hash.digest('hex'); | ||
} | ||
|
||
export const getStateInstance = (options: IIssuesProcessorOptions): IState => { | ||
const storage = new StateCacheStorage(); | ||
const cacheKey = sha256(JSON.stringify(options)); | ||
const storage = new StateCacheStorage(cacheKey); | ||
return new State(storage, options); | ||
}; |