Documentation ¶
Index ¶
- Variables
- func DisabledAsString(status bool) string
- func HashAsKey(hash uint64) string
- func PrettyBrandName(brand string) string
- func PrettyFuelType(ft string) string
- type List
- type LogEntry
- type Meta
- type Query
- type RegCountry
- type Store
- func (vs *Store) Clear() error
- func (vs *Store) Close() error
- func (vs *Store) CountLog() (int, error)
- func (vs *Store) Disable(hash string) error
- func (vs *Store) Enable(hash string) error
- func (vs *Store) GetLastSynced() (string, error)
- func (vs *Store) LastLog() (LogEntry, error)
- func (vs *Store) Log(msg string) error
- func (vs *Store) LookupByHash(hash string) (Vehicle, error)
- func (vs *Store) LookupByRegNr(rc RegCountry, regNr string, showDisabled bool) (Vehicle, error)
- func (vs *Store) LookupByVIN(rc RegCountry, VIN string, showDisabled bool) (Vehicle, error)
- func (vs *Store) NewSyncOp(source string) SyncOpID
- func (vs *Store) Open() error
- func (vs *Store) QueryTo(w io.Writer, q Query) error
- func (vs *Store) SetLastSynced(fname string) error
- func (vs *Store) Status(id SyncOpID) string
- func (vs *Store) Sync(id SyncOpID, vehicles <-chan Vehicle, done <-chan bool) error
- func (vs *Store) SyncVehicle(veh Vehicle) (bool, error)
- type SyncOpID
- type Type
- type Vehicle
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoSuchVehicle = errors.New("no such vehicle")
)
Exported errors.
Functions ¶
func DisabledAsString ¶
DisabledAsString returns a stringified version of the Disabled field.
func HashAsKey ¶
HashAsKey converts the given hash value into a string that can be used as key in the vehicle store.
func PrettyBrandName ¶
PrettyBrandName titles-cases the given brand name unless its length is 3 or below, in which case everything is uppercased. This should handle most cases.
func PrettyFuelType ¶
PrettyFuelType normalizes fuel-type by capitalizing the first letter only.
Types ¶
type LogEntry ¶
LogEntry contains two parts: a timestamp (logging time) and a message.
type Meta ¶
type Meta struct { Hash uint64 Source string Country RegCountry Ident uint64 LastUpdated time.Time Disabled bool }
Meta contains metadata for each vehicle.
type Query ¶
Query contains the search- and filter options for performing a query against the store.
type RegCountry ¶
type RegCountry int
RegCountry represents a country of registration for a vehicle.
const ( DK RegCountry = iota NO )
List of allowed registration countries.
func RegCountryFromString ¶
func RegCountryFromString(reg string) RegCountry
RegCountryFromString takes a string and returns the matching country of registration.
func (RegCountry) String ¶
func (reg RegCountry) String() string
String returns the string representation of the RegCountry.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store represents a Redis-compatible memory store such as Redis or Google Memory Store.
func NewStore ¶
func NewStore(storeCnf config.MemStoreConfig, syncCnf config.SyncConfig, logger io.Writer) *Store
NewStore returns a new Store, which you can then interact with in order to start sync operations etc.
func (*Store) Clear ¶
Clear clears out the entire vehicle store, including indexes but not the sync history.
func (*Store) GetLastSynced ¶
GetLastSynced returns the filename of the last file that was synchronised with the vehicle store. It returns an empty string if there is no filename.
func (*Store) LookupByHash ¶
LookupByHash performs a vehicle lookup by hash value, without side effects. Ie. it doesn't attempt to clear any indexes if no vehicle was found.
func (*Store) LookupByRegNr ¶
LookupByRegNr attempts to lookup a vehicle by its registration number.
func (*Store) LookupByVIN ¶
LookupByVIN attempts to lookup a vehicle by its VIN number.
func (*Store) NewSyncOp ¶
NewSyncOp starts a new synchronization operation and returns its id. Use this id for any further interactions with the operation. Note that his function is not thread-safe.
func (*Store) QueryTo ¶
QueryTo performs a query/search agsinst the store and streams the results to the provided reader.
func (*Store) SetLastSynced ¶
SetLastSynced replaces the logged filename of the file that was last synchronised with the vehicle store.
type SyncOpID ¶
type SyncOpID int
SyncOpID is an integer reference to a running synchronization operation.
type Type ¶
type Type int
Type represents the overall type of vehicle, ie. car, trailer, van etc.
func TypeFromString ¶
TypeFromString returns the Type that matches the given string (case insensitive match). If TypeFromString does not find a direct match, Type.Unknown is returned.
type Vehicle ¶
type Vehicle struct { MetaData Meta `hash:"ignore"` Type Type RegNr string VIN string Brand string Model string FuelType string Variant string FirstRegDate time.Time }
Vehicle contains the core vehicle data that Autobot manages. As vehicles are persisted in Redis / Google Memory Store, they should not contain pointers.
func (Vehicle) FlexString ¶
FlexString returns a stringified multi-line representation of the Vehicle data structure.
func (*Vehicle) GenHash ¶
GenHash generates a unique hash value of the vehicle. The hash is stored in the vehicle metadata.
func (Vehicle) Slice ¶
Slice returns most properties from Vehicle as a slice of strings, intended for use in CSV conversions.