Documentation ¶
Index ¶
- Constants
- Variables
- func ChangesetStateAt(ctx context.Context, timestamp time.Time) (ChangesetSeqNum, *State, error)
- func Changesets(ctx context.Context, n ChangesetSeqNum) (osm.Changesets, error)
- func CurrentChangesetState(ctx context.Context) (ChangesetSeqNum, *State, error)
- func CurrentDayState(ctx context.Context) (DaySeqNum, *State, error)
- func CurrentHourState(ctx context.Context) (HourSeqNum, *State, error)
- func CurrentMinuteState(ctx context.Context) (MinuteSeqNum, *State, error)
- func Day(ctx context.Context, n DaySeqNum) (*osm.Change, error)
- func DayStateAt(ctx context.Context, timestamp time.Time) (DaySeqNum, *State, error)
- func Hour(ctx context.Context, n HourSeqNum) (*osm.Change, error)
- func HourStateAt(ctx context.Context, timestamp time.Time) (HourSeqNum, *State, error)
- func Minute(ctx context.Context, n MinuteSeqNum) (*osm.Change, error)
- func MinuteStateAt(ctx context.Context, timestamp time.Time) (MinuteSeqNum, *State, error)
- func NotFound(err error) bool
- type ChangesetSeqNum
- type Datasource
- func (ds *Datasource) ChangesetState(ctx context.Context, n ChangesetSeqNum) (*State, error)
- func (ds *Datasource) ChangesetStateAt(ctx context.Context, timestamp time.Time) (ChangesetSeqNum, *State, error)
- func (ds *Datasource) Changesets(ctx context.Context, n ChangesetSeqNum) (osm.Changesets, error)
- func (ds *Datasource) CurrentChangesetState(ctx context.Context) (ChangesetSeqNum, *State, error)
- func (ds *Datasource) CurrentDayState(ctx context.Context) (DaySeqNum, *State, error)
- func (ds *Datasource) CurrentHourState(ctx context.Context) (HourSeqNum, *State, error)
- func (ds *Datasource) CurrentMinuteState(ctx context.Context) (MinuteSeqNum, *State, error)
- func (ds *Datasource) Day(ctx context.Context, n DaySeqNum) (*osm.Change, error)
- func (ds *Datasource) DayState(ctx context.Context, n DaySeqNum) (*State, error)
- func (ds *Datasource) DayStateAt(ctx context.Context, timestamp time.Time) (DaySeqNum, *State, error)
- func (ds *Datasource) Hour(ctx context.Context, n HourSeqNum) (*osm.Change, error)
- func (ds *Datasource) HourState(ctx context.Context, n HourSeqNum) (*State, error)
- func (ds *Datasource) HourStateAt(ctx context.Context, timestamp time.Time) (HourSeqNum, *State, error)
- func (ds *Datasource) Minute(ctx context.Context, n MinuteSeqNum) (*osm.Change, error)
- func (ds *Datasource) MinuteState(ctx context.Context, n MinuteSeqNum) (*State, error)
- func (ds *Datasource) MinuteStateAt(ctx context.Context, timestamp time.Time) (MinuteSeqNum, *State, error)
- type DaySeqNum
- type HourSeqNum
- type MinuteSeqNum
- type SeqNum
- type State
- type UnexpectedStatusCodeError
Constants ¶
const BaseURL = "https://planet.osm.org"
BaseURL defines the default planet server to hit.
const DaySeqStart = DaySeqNum(1)
DaySeqStart is the beginning of valid day sequence data.
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.
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 ¶
var DefaultDatasource = &Datasource{ Client: &http.Client{ Timeout: 30 * time.Minute, }, }
DefaultDatasource is the Datasource used by the package level convenience functions.
Functions ¶
func ChangesetStateAt ¶
ChangesetStateAt will return the replication state/sequence number that contains data for the given timestamp. This would be the first replication state written after the timestamp. If the timestamp is after all current replication state the most recent will be returned. The caller can check for this case using state.Before(givenTimestamp).
This call can do 20+ requests to the binary search the replication states. Use sparingly or use a mirror. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func Changesets ¶
func Changesets(ctx context.Context, n ChangesetSeqNum) (osm.Changesets, error)
Changesets returns the complete list of changesets 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 ¶
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 ¶
Day returns the change diff for a given day. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func DayStateAt ¶
DayStateAt will return the replication state/sequence number that contains data for the given timestamp. This would be the first replication state written after the timestamp. If the timestamp is after all current replication state the most recent will be returned. The caller can check for this case using state.Before(givenTimestamp).
This call can do 20+ requests to the binary search the replication states. Use sparingly or use a mirror. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func Hour ¶
Hour returns the change diff for a given hour. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func HourStateAt ¶
HourStateAt will return the replication state/sequence number that contains data for the given timestamp. This would be the first replication state written after the timestamp. If the timestamp is after all current replication state the most recent will be returned. The caller can check for this case using state.Before(givenTimestamp).
This call can do 20+ requests to the binary search the replication states. Use sparingly or use a mirror. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func Minute ¶
Minute returns the change diff for a given minute. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func MinuteStateAt ¶
MinuteStateAt will return the replication state/sequence number that contains data for the given timestamp. This would be the first replication state written after the timestamp. If the timestamp is after all current replication state the most recent will be returned. The caller can check for this case using state.Before(givenTimestamp).
This call can do 20+ requests to the binary search the replication states. Use sparingly or use a mirror. 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: https://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) ChangesetState ¶
func (ds *Datasource) ChangesetState(ctx context.Context, n ChangesetSeqNum) (*State, error)
ChangesetState returns the state for the given changeset replication. There are no state files before 2007990. In that case a 404 error is returned.
func (*Datasource) ChangesetStateAt ¶
func (ds *Datasource) ChangesetStateAt(ctx context.Context, timestamp time.Time) (ChangesetSeqNum, *State, error)
ChangesetStateAt will return the replication state/sequence number that contains data for the given timestamp. This would be the first replication state written after the timestamp. If the timestamp is after all current replication state the most recent will be returned. The caller can check for this case using state.Before(givenTimestamp).
This call can do 20+ requests to the binary search the replication states. Use sparingly or use a mirror.
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 ¶
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) DayStateAt ¶
func (ds *Datasource) DayStateAt(ctx context.Context, timestamp time.Time) (DaySeqNum, *State, error)
DayStateAt will return the replication state/sequence number that contains data for the given timestamp. This would be the first replication state written after the timestamp. If the timestamp is after all current replication state the most recent will be returned. The caller can check for this case using state.Before(givenTimestamp).
This call can do 20+ requests to the binary search the replication states. Use sparingly or use a mirror.
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) HourStateAt ¶
func (ds *Datasource) HourStateAt(ctx context.Context, timestamp time.Time) (HourSeqNum, *State, error)
HourStateAt will return the replication state/sequence number that contains data for the given timestamp. This would be the first replication state written after the timestamp. If the timestamp is after all current replication state the most recent will be returned. The caller can check for this case using state.Before(givenTimestamp).
This call can do 20+ requests to the binary search the replication states. Use sparingly or use a mirror.
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.
func (*Datasource) MinuteStateAt ¶
func (ds *Datasource) MinuteStateAt(ctx context.Context, timestamp time.Time) (MinuteSeqNum, *State, error)
MinuteStateAt will return the replication state/sequence number that contains data for the given timestamp. This would be the first replication state written after the timestamp. If the timestamp is after all current replication state the most recent will be returned. The caller can check for this case using state.Before(givenTimestamp).
This call can do 20+ requests to the binary search the replication states. Use sparingly or use a mirror.
type DaySeqNum ¶
type DaySeqNum uint64
DaySeqNum indicates the sequence of the daily diff replication found here: http://planet.osm.org/replication/day
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) 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) 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 ChangesetState ¶
func ChangesetState(ctx context.Context, n ChangesetSeqNum) (*State, error)
ChangesetState returns the state for the given changeset replication. There are no state files before 2007990. In that case a 404 error is returned. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func DayState ¶
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 ¶
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.