replication

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2018 License: MIT Imports: 12 Imported by: 0

README

osm/replication Godoc Reference

Package replication handles fetching the Minute, Hour, Day and Changeset replication and the assocated state value from Planet OSM.

For example, to fetch the current Minute replication state:

num, fullState, err := replication.CurrentMinuteState(ctx)

This is the data in http://planet.osm.org/replication/minute/state.txt updated every minute.

Once you know the change number you want, fetch the change using:

change, err := replication.Minute(ctx, num)

Documentation

Index

Constants

View Source
const BaseURL = "http://planet.osm.org"

BaseURL defines the planet server to hit.

View Source
const DaySeqStart = DaySeqNum(1)

DaySeqStart is the beginning of valid day sequence data.

View Source
const HourSeqStart = HourSeqNum(11)

HourSeqStart is the beginning of valid hour sequence data. Without deep inspection it looks like 1-10 are from July 2013.

View Source
const MinuteSeqStart = MinuteSeqNum(4)

MinuteSeqStart is the beginning of valid minutely sequence data. The few before look to be way more than a minute. A quick looks says about 75, 57, 17 for 1, 2, 3 respectively.

Variables

View Source
var DefaultDatasource = &Datasource{
	Client: &http.Client{
		Timeout: 30 * time.Minute,
	},
}

DefaultDatasource is the Datasource used by the package level convenience functions.

Functions

func Changesets

func Changesets(ctx context.Context, n ChangesetSeqNum) (osm.Changesets, error)

Changesets returns the complete list of changesets in for the given replication sequence. Delegates to the DefaultDatasource and uses its http.Client to make the request.

func CurrentChangesetState

func CurrentChangesetState(ctx context.Context) (ChangesetSeqNum, *State, error)

CurrentChangesetState returns the current state of the changeset replication. Delegates to the DefaultDatasource and uses its http.Client to make the request.

func CurrentDayState

func CurrentDayState(ctx context.Context) (DaySeqNum, *State, error)

CurrentDayState returns the current state of the daily replication. Delegates to the DefaultDatasource and uses its http.Client to make the request.

func CurrentHourState

func CurrentHourState(ctx context.Context) (HourSeqNum, *State, error)

CurrentHourState returns the current state of the hourly replication. Delegates to the DefaultDatasource and uses its http.Client to make the request.

func CurrentMinuteState

func CurrentMinuteState(ctx context.Context) (MinuteSeqNum, *State, error)

CurrentMinuteState returns the current state of the minutely replication. Delegates to the DefaultDatasource and uses its http.Client to make the request.

func Day

func Day(ctx context.Context, n DaySeqNum) (*osm.Change, error)

Day returns the change diff for a given day. Delegates to the DefaultDatasource and uses its http.Client to make the request.

func Hour

func Hour(ctx context.Context, n HourSeqNum) (*osm.Change, error)

Hour returns the change diff for a given hour. Delegates to the DefaultDatasource and uses its http.Client to make the request.

func Minute

func Minute(ctx context.Context, n MinuteSeqNum) (*osm.Change, error)

Minute returns the change diff for a given minute. Delegates to the DefaultDatasource and uses its http.Client to make the request.

Types

type ChangesetSeqNum

type ChangesetSeqNum uint64

ChangesetSeqNum indicates the sequence of the changeset replication found here: http://planet.osm.org/replication/changesets/

func (ChangesetSeqNum) Dir

func (n ChangesetSeqNum) Dir() string

Dir returns the directory of this data on planet osm.

func (ChangesetSeqNum) String

func (n ChangesetSeqNum) String() string

String returns 'changeset/%d'.

func (ChangesetSeqNum) Uint64

func (n ChangesetSeqNum) Uint64() uint64

Uint64 returns the seq num as a uint64 type.

type Datasource

type Datasource struct {
	BaseURL string // will use package level BaseURL if empty
	Client  *http.Client
}

Datasource defines context around replication data requests.

func NewDatasource

func NewDatasource(client *http.Client) *Datasource

NewDatasource creates a Datasource using the given client.

func (*Datasource) Changesets

func (ds *Datasource) Changesets(ctx context.Context, n ChangesetSeqNum) (osm.Changesets, error)

Changesets returns the complete list of changesets in for the given replication sequence.

func (*Datasource) CurrentChangesetState

func (ds *Datasource) CurrentChangesetState(ctx context.Context) (ChangesetSeqNum, *State, error)

CurrentChangesetState returns the current state of the changeset replication.

func (*Datasource) CurrentDayState

func (ds *Datasource) CurrentDayState(ctx context.Context) (DaySeqNum, *State, error)

CurrentDayState returns the current state of the daily replication.

func (*Datasource) CurrentHourState

func (ds *Datasource) CurrentHourState(ctx context.Context) (HourSeqNum, *State, error)

CurrentHourState returns the current state of the hourly replication.

func (*Datasource) CurrentMinuteState

func (ds *Datasource) CurrentMinuteState(ctx context.Context) (MinuteSeqNum, *State, error)

CurrentMinuteState returns the current state of the minutely replication.

func (*Datasource) Day

func (ds *Datasource) Day(ctx context.Context, n DaySeqNum) (*osm.Change, error)

Day returns the change diff for a given day.

func (*Datasource) DayState

func (ds *Datasource) DayState(ctx context.Context, n DaySeqNum) (*State, error)

DayState returns the state of the given daily replication.

func (*Datasource) Hour

func (ds *Datasource) Hour(ctx context.Context, n HourSeqNum) (*osm.Change, error)

Hour returns the change diff for a given hour.

func (*Datasource) HourState

func (ds *Datasource) HourState(ctx context.Context, n HourSeqNum) (*State, error)

HourState returns the state of the given hourly replication.

func (*Datasource) Minute

func (ds *Datasource) Minute(ctx context.Context, n MinuteSeqNum) (*osm.Change, error)

Minute returns the change diff for a given minute.

func (*Datasource) MinuteState

func (ds *Datasource) MinuteState(ctx context.Context, n MinuteSeqNum) (*State, error)

MinuteState returns the state of the given minutely replication.

type DaySeqNum

type DaySeqNum uint64

DaySeqNum indicates the sequence of the daily diff replication found here: http://planet.osm.org/replication/day

func (DaySeqNum) Dir

func (n DaySeqNum) Dir() string

Dir returns the directory of this data on planet osm.

func (DaySeqNum) String

func (n DaySeqNum) String() string

String returns 'day/%d'.

func (DaySeqNum) Uint64

func (n DaySeqNum) Uint64() uint64

Uint64 returns the seq num as a uint64 type.

type HourSeqNum

type HourSeqNum uint64

HourSeqNum indicates the sequence of the hourly diff replication found here: http://planet.osm.org/replication/hour

func (HourSeqNum) Dir

func (n HourSeqNum) Dir() string

Dir returns the directory of this data on planet osm.

func (HourSeqNum) String

func (n HourSeqNum) String() string

String returns 'hour/%d'.

func (HourSeqNum) Uint64

func (n HourSeqNum) Uint64() uint64

Uint64 returns the seq num as a uint64 type.

type MinuteSeqNum

type MinuteSeqNum uint64

MinuteSeqNum indicates the sequence of the minutely diff replication found here: http://planet.osm.org/replication/minute

func (MinuteSeqNum) Dir

func (n MinuteSeqNum) Dir() string

Dir returns the directory of this data on planet osm.

func (MinuteSeqNum) String

func (n MinuteSeqNum) String() string

String returns 'minute/%d'.

func (MinuteSeqNum) Uint64

func (n MinuteSeqNum) Uint64() uint64

Uint64 returns the seq num as a uint64 type.

type SeqNum

type SeqNum interface {
	fmt.Stringer
	Dir() string
	Uint64() uint64
	// contains filtered or unexported methods
}

SeqNum is an interface type that includes MinuteSeqNum, HourSeqNum and DaySeqNum. This is an experiment to implement a sum type, a type that can be one of several things only.

type State

type State struct {
	SeqNum        uint64    `json:"seq_num"`
	Timestamp     time.Time `json:"timestamp"`
	TxnMax        int       `json:"txn_max,omitempty"`
	TxnMaxQueried int       `json:"txn_max_queries,omitempty"`
}

State returns information about the current replication state.

func DayState

func DayState(ctx context.Context, n DaySeqNum) (*State, error)

DayState returns the state of the given daily replication. Delegates to the DefaultDatasource and uses its http.Client to make the request.

func HourState

func HourState(ctx context.Context, n HourSeqNum) (*State, error)

HourState returns the state of the given hourly replication. Delegates to the DefaultDatasource and uses its http.Client to make the request.

func MinuteState

func MinuteState(ctx context.Context, n MinuteSeqNum) (*State, error)

MinuteState returns the state of the given minutely replication. Delegates to the DefaultDatasource and uses its http.Client to make the request.

type UnexpectedStatusCodeError

type UnexpectedStatusCodeError struct {
	Code int
	URL  string
}

UnexpectedStatusCodeError is return for a non 200 or 404 status code.

func (*UnexpectedStatusCodeError) Error

func (e *UnexpectedStatusCodeError) Error() string

Error returns an error message with some information.

Jump to

Keyboard shortcuts

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