direct

package
v0.0.0-...-543ca17 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 3 Imported by: 0

README

Direct endpoint

Direct endpoint implements Endpoint interface by extending BaseEndpoint type. This endpoint allows communication between code running in the same process by utilizing channels internally.

It uses a dndm.Linker to link Intents and Interests together internally.

Intent and Interest Routes must match for the link to happen, meaning that both the path and the message types must match exactly.

Documentation

Overview

Package direct provides a concrete implementation of the dndm.Endpoint interface, facilitating direct communications by managing links between intents and interests. It integrates robust lifecycle management and ensures proper resource handling through its BaseEndpoint and custom Linker logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	dndm.BaseEndpoint
	// contains filtered or unexported fields
}

func New

func New(size int) *Endpoint

New creates and returns a new instance of Endpoint with specified buffer size. The size parameter affects internal buffering and link management capacities.

func (*Endpoint) Close

func (t *Endpoint) Close() error

Close terminates the Endpoint and cleans up resources, particularly closing the internal Linker if it has been initialized. It ensures all associated resources are properly released.

func (*Endpoint) Init

func (t *Endpoint) Init(ctx context.Context, logger *slog.Logger, addIntent dndm.IntentCallback, addInterest dndm.InterestCallback) error

Init initializes the Endpoint with necessary context, logging, and callbacks for intents and interests. This setup is crucial for the Endpoint to function properly within a networked environment, ensuring that it can handle incoming and outgoing data flows as expected.

func (*Endpoint) OnClose

func (t *Endpoint) OnClose(f func()) dndm.Endpoint

OnClose registers a callback function that will be invoked when the endpoint is closed. This method allows for cleanup activities or notifications to be scheduled upon closure.

func (*Endpoint) Publish

func (t *Endpoint) Publish(route dndm.Route, opt ...dndm.PubOpt) (dndm.Intent, error)

Publish creates and registers a new intent based on the provided route. This method leverages the internal Linker to manage the intent lifecycle and connectivity.

func (*Endpoint) Subscribe

func (t *Endpoint) Subscribe(route dndm.Route, opt ...dndm.SubOpt) (dndm.Interest, error)

Subscribe creates and registers a new interest based on the provided route. Similar to Publish, this method uses the internal Linker to manage the interest and ensure it is properly integrated within the networked environment.

Jump to

Keyboard shortcuts

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