gokaf

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 11 Imported by: 0

README

gokaf

coverage Go Report Card MIT License Go Reference

gokaf a straightforward, in-memory pubsub engine designed to facilitate nearly real-time data streams.

Overview

gokaf is a robust in-memory pubsub engine meticulously crafted to provide seamless and nearly real-time data streams.

This module is strategically constructed on the foundation of Golang channels, employing a highly efficient pubsub messaging approach.

By harnessing the inherent simplicity and concurrency features of Golang, gokaf excels in real-time message processing, offering an agile and responsive solution for applications with low-latency requirements in memory data processing.

The design principles of gokaf are centered around optimal performance.

Documentation

Overview

gokaf is a robust in-memory pubsub engine meticulously crafted to provide seamless and nearly real-time data streams.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

type Consumer struct {
	// contains filtered or unexported fields
}

Consumer struct represents a subscriber in the pubsub system.

func (*Consumer) Run

func (c *Consumer) Run()

Run initiates the consumer's message consumption process by starting a goroutine.

func (*Consumer) Stop

func (c *Consumer) Stop()

Stop stops the consumer, terminating its message processing loop and releasing associated resources.

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine struct represents the core of a pubsub system, managing topics and their associated consumers.

func NewEngine

func NewEngine(logger *slog.Logger) *Engine

NewEngine creates a new Engine instance, initializing the necessary components for the pubsub system.

func (*Engine) GetConsumer

func (e *Engine) GetConsumer(topicName string, handler func(interface{})) (*Consumer, error)

GetConsumer retrieves or creates a new consumer associated with the specified topic in the pubsub engine.

func (*Engine) GetProducer

func (e *Engine) GetProducer(topicName string) (*Producer, error)

GetProducer retrieves or creates a new producer associated with the specified topic in the pubsub engine.

func (*Engine) RegisterTopic

func (e *Engine) RegisterTopic(topicName string, bufferSize int) error

RegisterTopic creates and registers a new topic within the pubsub engine with the specified name and buffer size.

func (*Engine) Stop

func (e *Engine) Stop()

Stop terminates the pubsub engine, initiating a graceful shutdown process.

func (*Engine) TopicExists

func (e *Engine) TopicExists(topicName string) bool

TopicExists checks if a specified topic exists within the pubsub engine.

type Producer

type Producer struct {
	// contains filtered or unexported fields
}

Producer struct represents a message producer in the pubsub system.

func (*Producer) Publish

func (p *Producer) Publish(message interface{}) error

Publish sends a message to the associated topic through the producer.

func (*Producer) Stop

func (p *Producer) Stop()

Stop gracefully stops the producer by canceling its context and waiting for associated tasks to complete.

type TopicClosedError

type TopicClosedError struct {
	// contains filtered or unexported fields
}

TopicClosedError is a custom error type for indicating that a topic is already closed.

func (TopicClosedError) Error

func (e TopicClosedError) Error() string

Error returns a string representation of the TopicClosedError.

type TopicExistsError

type TopicExistsError struct {
	// contains filtered or unexported fields
}

TopicExistsError is a custom error type for indicating that a topic already exists.

func (TopicExistsError) Error

func (e TopicExistsError) Error() string

Error returns a string representation of the TopicExistsError.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL