![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
simple-async-tasks
Advanced tools
Changelog
Readme
easily create and use async-tasks within a pit-of-success
npm install simple-async-tasks
define the domain object of the async task you want to be able to run
import { DomainEntity } from 'domain-objects';
import { AsyncTask, AsyncTaskStatus } from 'simple-async-tasks';
/**
* for example: an async task for emitting some data to remote persistance
*/
export interface AsyncTaskEmitToRemote extends AsyncTask {
uuid?: string;
updatedAt?: string;
status: AsyncTaskStatus;
/**
* the endpoint to emit the data to
*/
endpoint: string;
/**
* the payload to emit
*
* note
* - supports string and binary buffer
*/
payload: string | Buffer;
}
export class AsyncTaskEmitToRemote
extends DomainEntity<AsyncTaskEmitToRemote>
implements AsyncTaskEmitToRemote
{
public static unique = ['endpoint', 'payload'];
}
define the database-access-object we can use to persist this async-task
usually, you should be using a library to code-generate or instantiate the dao for you
for example
import { createCacheDao } from 'simple-cache-dao';
import { createCache } from 'simple-in-memory-cache';
const daoTaskEmitToRemote = createCacheDao({ cache: createCache() })
define how to queue your task for execution
import { createQueue, QueueOrder } from 'simple-in-memory-queue';
// TODO: load all queued tasks from db on page load
export const asyncTaskEmitToRemoteQueue = createQueue<AsyncTaskEmitToRemote>({
order: QueueOrder.FIRST_IN_FIRST_OUT,
});
export const queueTaskEmitToRemote = withAsyncTaskExecutionLifecycleQueue({
dao: daoTaskEmitToRemote,
queue: asyncTaskEmitToRemoteQueue,
getNew: ({ endpoint, payload }) =>
new AsyncTaskEmitToRemote({
status: AsyncTaskStatus.QUEUED,
endpoint,
payload,
}),
});
define how to execute your async task
export const executeTaskEmitToRemote = withAsyncTaskExecutionLifecycleExecute(
async ({ task }: { task: HasMetadata<AsyncTaskEmitToRemote> }) => {
// execute your logic
// mark it as fulfilled
await daoTaskEmitToRemote.upsert({ task: { ...task, status: AsyncTaskStatus.FULFILLED }})
},
{
dao: daoTaskEmitToRemote,
},
);
⚠️ note: you must change the status of the task away from attempted by the time the execute function resolves to some non-attempted , otherwise it will be considered a failure
define the trigger that will consume from your queue and invoke the execute function
note
FAQs
A simple in-memory queue, for nodejs and the browser, with consumers for common usecases.
The npm package simple-async-tasks receives a total of 52 weekly downloads. As such, simple-async-tasks popularity was classified as not popular.
We found that simple-async-tasks demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.