postalpool

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package postalpool provides a service for managing multiple libpostal process instances and a client for distributing requests across them in a round-robin fashion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides thread-safe access to a pool of libpostal processes, distributing requests across them in a round-robin fashion. Each request is automatically routed to the next available worker process.

Requests will be queued up on workers and start to block if every worker has an active request. libpostal is single threaded.

Client maintains an address pool to the worker processes. It provides a simple API that hides the complexity of working with multiple postal processes.

func NewClient

func NewClient(conf Config, endpoints []string) *Client

func (*Client) ParseAddress

func (c *Client) ParseAddress(ctx context.Context, input string) (search.Address, error)

type Config

type Config struct {
	Enabled bool

	Instances      int
	StartingPort   int
	StartupTimeout time.Duration

	RequestTimeout time.Duration

	BinaryPath string
}

type Service

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

Service spawns a pool of libpostal process instances. It handles running and graceful shutdown of worker processes. Each worker process has its own isolated copy of libpostal's global state, allowing for concurrent processing without contention.

A Service should be created via NewService() and stopped using the Shutdown() method when no longer needed. The Service ensures all worker processes are properly terminated on shutdown.

func NewService

func NewService(logger log.Logger, conf Config) (*Service, error)

func (*Service) ParseAddress

func (ps *Service) ParseAddress(ctx context.Context, input string) (search.Address, error)

func (*Service) Shutdown

func (ps *Service) Shutdown()

Jump to

Keyboard shortcuts

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