From 9fb220096a8a50bd89f0d7578d572629531f8141 Mon Sep 17 00:00:00 2001 From: Alexander Neonxp Kiryukhin Date: Sat, 24 Jan 2026 17:56:58 +0300 Subject: v1.0.1 --- README.md | 76 +++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 26 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 2ec98d8..6f777fe 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,26 @@ # eventbus - Асинхронная шина событий для Go -[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) +[![License: GPL +v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [English version below](#english-version) -`eventbus` - это реализация асинхронной шины событий для языка программирования Go. Библиотека предоставляет механизм публикации и подписки на события с использованием trie-структуры для эффективного управления подписками. +`eventbus` - это реализация асинхронной шины событий для языка программирования +Go. Библиотека предоставляет механизм публикации и подписки на события с +использованием trie-структуры для эффективного управления подписками. ## Особенности -- **Trie-структура**: Использует префиксное дерево для хранения подписок, что обеспечивает эффективный поиск подписчиков -- **Конфигурируемость**: Поддерживает настройку разделителя имен и символа wildcard через опции конструктора -- **Асинхронная доставка**: События доставляются подписчикам асинхронно, что предотвращает блокировку отправителя -- **Потокобезопасность**: Все операции синхронизированы с использованием `sync.RWMutex` -- **Обобщения**: Реализована с использованием обобщений Go 1.18+, что позволяет использовать любые сравнимые типы +- **Trie-структура**: Использует префиксное дерево для хранения подписок, что + обеспечивает эффективный поиск подписчиков +- **Конфигурируемость**: Поддерживает настройку разделителя имен и символа + wildcard через опции конструктора +- **Асинхронная доставка**: События доставляются подписчикам асинхронно, что + предотвращает блокировку отправителя +- **Потокобезопасность**: Все операции синхронизированы с использованием + `sync.RWMutex` +- **Обобщения**: Реализована с использованием обобщений Go 1.18+, что позволяет + использовать любые сравнимые типы ## Установка @@ -95,15 +103,18 @@ func main() { ### `func New(opts ...Opt) *bus` -Создает новую шину событий с опциональными настройками. Поддерживает следующие опции: +Создает новую шину событий с опциональными настройками. Поддерживает следующие +опции: - `NameSeparator` - задает разделитель имен событий (по умолчанию ".") -- `Wildcard` - задает символ wildcard для подписок (по умолчанию "*") -- `Capacity` - задает начальную емкость для каналов подписчиков (по умолчанию 32) +- `Wildcard` - задает символ wildcard для подписок (по умолчанию "\*") +- `Capacity` - задает начальную емкость для узлов дерева подписчиков (по + умолчанию 32) ### `func (b *bus) Subscribe(path string) Listener` -Подписывается на событие по указанному пути. Возвращает канал-подписчик для получения событий. +Подписывается на событие по указанному пути. Возвращает канал-подписчик для +получения событий. ### `func (b *bus) Unsubscribe(l Listener)` @@ -115,11 +126,13 @@ func main() { ### `func (b *bus) Fire(ev Event)` -Отправляет событие всем подписчикам, которые подписаны на соответствующий путь события. +Отправляет событие всем подписчикам, которые подписаны на соответствующий путь +события. ## Лицензия -Этот проект лицензирован в соответствии с GNU General Public License версии 3 (GPLv3). Подробности смотрите в файле [LICENSE](LICENSE). +Этот проект лицензирован в соответствии с GNU General Public License версии 3 +(GPLv3). Подробности смотрите в файле [LICENSE](LICENSE). ``` GNU GENERAL PUBLIC LICENSE @@ -132,20 +145,27 @@ func main() { ## Ссылки -- **Репозиторий**: [https://gitrepo.ru/NeonXP/eventbus.git](https://gitrepo.ru/NeonXP/eventbus.git) +- **Репозиторий**: + [https://gitrepo.ru/NeonXP/eventbus.git](https://gitrepo.ru/NeonXP/eventbus.git) - **Автор**: Alexander NeonXP Kiryukhin # English Version -`eventbus` is an implementation of an asynchronous event bus for the Go programming language. The library provides a publish-subscribe mechanism for events using a trie structure for efficient subscription management. +`eventbus` is an implementation of an asynchronous event bus for the Go +programming language. The library provides a publish-subscribe mechanism for +events using a trie structure for efficient subscription management. ## Features -- **Trie structure**: Uses a prefix tree to store subscriptions, providing efficient subscriber lookup -- **Configurable**: Supports configuration of name separator and wildcard character through constructor options -- **Asynchronous delivery**: Events are delivered to subscribers asynchronously, preventing sender blocking +- **Trie structure**: Uses a prefix tree to store subscriptions, providing + efficient subscriber lookup +- **Configurable**: Supports configuration of name separator and wildcard + character through constructor options +- **Asynchronous delivery**: Events are delivered to subscribers asynchronously, + preventing sender blocking - **Thread-safe**: All operations are synchronized using `sync.RWMutex` -- **Generics**: Implemented using Go 1.18+ generics, allowing any comparable types +- **Generics**: Implemented using Go 1.18+ generics, allowing any comparable + types ## Installation @@ -231,12 +251,13 @@ func main() { Creates a new event bus with optional settings. Supports the following options: - `NameSeparator` - sets the event name separator (default ".") -- `Wildcard` - sets the wildcard character for subscriptions (default "*") -- `Capacity` - sets the initial capacity for listener channels (default 32) +- `Wildcard` - sets the wildcard character for subscriptions (default "\*") +- `Capacity` - sets the initial capacity for listeners trie (default 32) ### `func (b *bus) Subscribe(path string) Listener` -Subscribes to an event at the specified path. Returns a listener channel for receiving events. +Subscribes to an event at the specified path. Returns a listener channel for +receiving events. ### `func (b *bus) Unsubscribe(l Listener)` @@ -248,11 +269,13 @@ Closes the event bus and all listener channels. ### `func (b *bus) Fire(ev Event)` -Fires an event to all subscribers who are subscribed to the corresponding event path. +Fires an event to all subscribers who are subscribed to the corresponding event +path. ## License -This project is licensed under the GNU General Public License version 3 (GPLv3). See the [LICENSE](LICENSE) file for details. +This project is licensed under the GNU General Public License version 3 (GPLv3). +See the [LICENSE](LICENSE) file for details. ``` GNU GENERAL PUBLIC LICENSE @@ -265,5 +288,6 @@ This project is licensed under the GNU General Public License version 3 (GPLv3). ## Links -- **Repository**: [https://gitrepo.ru/NeonXP/eventbus.git](https://gitrepo.ru/NeonXP/eventbus.git) -- **Author**: Alexander NeonXP Kiryukhin \ No newline at end of file +- **Repository**: + [https://gitrepo.ru/NeonXP/eventbus.git](https://gitrepo.ru/NeonXP/eventbus.git) +- **Author**: Alexander NeonXP Kiryukhin -- cgit v1.2.3