import { KyselySemaphoreAdapter } from "@daiso-tech/core/semaphore/kysely-semaphore-adapter";
import { SemaphoreProvider } from "@daiso-tech/core/semaphore";
import { Serde } from "@daiso-tech/core/serde";
import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/super-json-serde-adapter";
import Sqlite from "better-sqlite3";
import { Kysely, SqliteDialect } from "kysely";
const semaphoreAdapter = new KyselySemaphoreAdapter({
kysely: new Kysely({
dialect: new SqliteDialect({
database: new Sqlite("local.db"),
}),
});
});
// You need initialize the adapter once before using it.
await semaphoreAdapter.init();
const serde = new Serde(new SuperJsonSerdeAdapter())
const lockProvider = new SemaphoreProvider({
serde,
adapter: semaphoreAdapter,
});
You can listen to the following SemaphoreEventMap of all ISemaphore instances created by the ISemaphoreProvider.
To understand how this method works, refer to IEventListenable .
You can listen to the following SemaphoreEventMap of all ISemaphore instances created by the ISemaphoreProvider.
To understand how this method works, refer to IEventListenable .
The create method is used to create an instance of ISemaphore.
can be a string or an Iterable of strings.
If it's an Iterable, it will be joined into a single string.
Think of an Iterable as representing a path.
You can listen to the following SemaphoreEventMap of all ISemaphore instances created by the ISemaphoreProvider.
To understand how this method works, refer to IEventListenable .
You can listen to the following SemaphoreEventMap of all ISemaphore instances created by the ISemaphoreProvider.
To understand how this method works, refer to IEventListenable .
You can listen to the following SemaphoreEventMap of all ISemaphore instances created by the ISemaphoreProvider.
To understand how this method works, refer to IEventListenable .
You can listen to the following SemaphoreEventMap of all ISemaphore instances created by the ISemaphoreProvider.
To understand how this method works, refer to IEventListenable .
SemaphoreProviderclass can be derived from anyISemaphoreAdapterorIDatabaseSemaphoreAdapter.Note the
ISemaphoreinstances created by theSemaphoreProviderclass are serializable and deserializable, allowing them to be seamlessly transferred across different servers, processes, and databases. This can be done directly usingISerderRegisteror indirectly through components that rely onISerderRegisterinternally.IMPORT_PATH:
"@daiso-tech/core/semaphore"