gopostalmulti

package module
v2.0.0-...-8ede4a0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: MIT Imports: 8 Imported by: 0

README

This is a fork of github.com/mzimmerman/gopostalmulti

It provides additional configuration, along with change of syntax to allow forking of commands in the background to parse addresses.

It doesn't require the Go library bindings for libpostal, just compiled binary of cmd/gopostalcmd.c as gopostalcmdc in the search path. Communication is via stdio + msgpack, so you could use generate a pure Go compiled gopostalmulti.

gopostalmulti

libpostal is not multicore, so this forks commands in the background (as needed) to help parse additional addresses

Usage

Code:

package main

import (
	"fmt"
	"runtime"

	"gopkg.in/tuxuri/gopostalmulti.v2"
)

func main() {
	backends := runtime.NumCPU() / 2 // Default is NumCPU(), but we'll reduce it for this example
	if backends <= 1 {
		backends = 1
	}
	libpostal := gopostalmulti.Libpostal{
		Path: "/usr/local/bin/gopostalmultic",
		MaxBackend: backends,
	}
	// Do checks and updates before parsing.
	
	libpostal.Init() // Actually loads and spawns the C backends.
	data := libpostal.Parse("Kuala Lumpur")
	fmt.Printf("%+v\n", data)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Libpostal

type Libpostal struct {
	Path        string
	MaxBackends int
	Expiry      time.Duration
	// contains filtered or unexported fields
}

func (*Libpostal) Init

func (l *Libpostal) Init()

Init takes the preferred configured settings and spins up the backends

func (*Libpostal) Parse

func (l *Libpostal) Parse(address string) [][2]string

Parse will parse addresses and return postal components can be called concurrently. Warning: this does not check if Init() has been called

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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