diff --git a/README.md b/README.md index d1e2397..9dc23cd 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ HamokRecord is a feature that provides distributed storage for individual record ## User Manual -You can find detailed user manuals [here](www.hamok.dev) +You can find detailed user manuals [here](http://www.hamok.dev) ## Contributing diff --git a/docs/emitter.md b/docs/emitter.md index 28acf9a..01ed6b7 100644 --- a/docs/emitter.md +++ b/docs/emitter.md @@ -1,17 +1,6 @@ ## User Manual [Hamok](./index.md) | HamokEmitter | [HamokMap](./map.md) | [HamokQueue](./queue.md) | [HamokRecord](./record.md) -## Table of Contents -* [Overview](#overview) -* [API Reference](#api-reference) - * [Create a HamokEmitter instance](#create-a-hamokemitter-instance) - * [Configuration](#configuration) - * [Events](#events) - * [Properties](#properties) - * [Methods](#methods) -* [Examples](#examples) -* [FAQ](#faq) - ## Table of Contents * [Overview](#overview) * [Configuration](#configuration) diff --git a/docs/index.md b/docs/index.md index 1adf6b0..8eb96f7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7,13 +7,15 @@ 2. [Installation](#installation) 3. [Configuration](#configuration) 4. [API Reference](#api-reference) - - [Hamok Class](#hamok-class) - - [Executing Tasks on the leader](#executing-tasks-on-the-leader) - - [Creating and Managing Maps](#creating-and-managing-maps) - - [Creating and Managing Records](#creating-and-managing-records) - - [Creating and Managing Queues](#creating-and-managing-queues) - - [Creating and Managing Emitters](#creating-and-managing-emitters) -5. [Events](#events) + - [Properties](#properties) + - [Events](#events) + - [Methods](#methods) +5. [Use Cases](#use-cases) + - [Executing Tasks on the leader](#executing-tasks-on-the-leader) + - [Creating and Managing Maps](#creating-and-managing-maps) + - [Creating and Managing Records](#creating-and-managing-records) + - [Creating and Managing Queues](#creating-and-managing-queues) + - [Creating and Managing Emitters](#creating-and-managing-emitters) 6. [Snapshots](#snapshots) 7. [Error Handling](#error-handling) 8. [Examples](#examples) @@ -90,11 +92,9 @@ const config = { const hamok = new Hamok(config); ``` -## API Reference +## API Reference `Hamok` -### `Hamok` Class - -#### Properties +### Properties - `config`: `HamokConfig` - The configuration object for the Hamok instance. @@ -132,7 +132,27 @@ const hamok = new Hamok(config); - `run`: `boolean` - A boolean indicating if the Raft timer is running. -#### Methods +### Events + +Hamok emits various events that can be listened to for handling specific actions. + +- `started`: Emitted when the Hamok instance starts. +- `stopped`: Emitted when the Hamok instance stops. +- `follower`: Emitted when the instance becomes a follower. +- `leader`: Emitted when the instance becomes the leader. +- `message`: Emitted when a message is received. +- `remote-peer-joined`: Emitted when a remote peer joins. +- `remote-peer-left`: Emitted when a remote peer leaves. +- `leader-changed`: Emitted when the leader changes. +- `state-changed`: Emitted when the state changes. +- `commit`: Emitted when a commit occurs. +- `heartbeat`: Emitted during heartbeats. +- `error`: Emitted when an error occurs. +- `hello-notification`: Emitted when a hello notification is received. +- `no-heartbeat-from`: Emitted when no heartbeat is received from a peer. + + +### Methods - **constructor**(`providedConfig?: Partial`): - Creates a new Hamok instance with the provided configuration. @@ -179,6 +199,8 @@ const hamok = new Hamok(config); - **fetchRemotePeers**(`options?: { customRequest?: string, timeoutInMs?: number }`): `Promise` - Fetches remote peers with optional custom requests and timeout. +## Use cases + ### Executing Tasks on the leader ```typescript @@ -271,25 +293,6 @@ emitter.emit('event'); ``` -## Events - -Hamok emits various events that can be listened to for handling specific actions. - -- `started`: Emitted when the Hamok instance starts. -- `stopped`: Emitted when the Hamok instance stops. -- `follower`: Emitted when the instance becomes a follower. -- `leader`: Emitted when the instance becomes the leader. -- `message`: Emitted when a message is received. -- `remote-peer-joined`: Emitted when a remote peer joins. -- `remote-peer-left`: Emitted when a remote peer leaves. -- `leader-changed`: Emitted when the leader changes. -- `state-changed`: Emitted when the state changes. -- `commit`: Emitted when a commit occurs. -- `heartbeat`: Emitted during heartbeats. -- `error`: Emitted when an error occurs. -- `hello-notification`: Emitted when a hello notification is received. -- `no-heartbeat-from`: Emitted when no heartbeat is received from a peer. - ## Snapshots Hamok supports exporting and importing snapshots for persistence and recovery.