storage

package
v0.0.0-...-0852b67 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

package storage stores the MLS listing data collected from the collectors.

Index

Constants

View Source
const (
	Open listingStatus = iota
	Pending
	Sold
)

Variables

This section is empty.

Functions

This section is empty.

Types

type City

type City struct {
	Name      string
	State     string
	MlsNumber map[string]bool
}

type DB

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

func NewDBStorage

func NewDBStorage() (*DB, error)

func (*DB) CreateStorage

func (d *DB) CreateStorage() error

func (*DB) ReadListing

func (d *DB) ReadListing(id string) (string, error)

func (*DB) ReadListings

func (d *DB) ReadListings() (*mlspb.Listings, error)

func (*DB) SaveNewListing

func (d *DB) SaveNewListing(mlsNumber string, listing *mlspb.Property) error

func (*DB) UpdateListing

func (d *DB) UpdateListing(mlsNumber string, p *mlspb.Property) error

type DBInterface

type DBInterface interface {
	CreateStorage() error
	SaveNewListing(p *mlspb.Property) error
	UpdateListing(p *mlspb.Property) error
	ReadListing(id string) (string, error)
	ReadListings() (*mlspb.Listings, error)
}

DBInterface defines the common interface for all types of storage implemented.

type MemoryDB

type MemoryDB struct {
	Lock         sync.Mutex
	Mls          map[string]*mls
	Property     map[string]*property
	Photo        map[string]*photo
	PriceHistory map[string][]*priceHistory
	CityIndex    map[string]*City
}

MemoryDB creates the in-memory data structure to hold the collected data.

func NewMemoryDB

func NewMemoryDB(cityIndex map[string]*City) (*MemoryDB, error)

NewMemoryDB creates an instance of all the in-memory data structure used to hold the collected data. cityIndex is in the format of map[string]*City

ie. map[string]*City{
	 "windsor,ontario": &City{
		 Name: "Windsor",
		 State: "Ontario",
		 MlsNumber: make(map[string]bool)
	 }
}

func (*MemoryDB) CreateStorage

func (m *MemoryDB) CreateStorage() error

CreateStorage for in-memory DB is a placeholder to comply with the DBInterface.

func (*MemoryDB) ReadListing

func (m *MemoryDB) ReadListing(id string) (string, error)

ReadListing reads a listing by listing ID from the in-memory data structure.

func (*MemoryDB) ReadListings

func (m *MemoryDB) ReadListings() (*mlspb.Listings, error)

ReadListings reads all MLS listings collected from the in-memory data structure.

func (*MemoryDB) SaveNewListing

func (m *MemoryDB) SaveNewListing(p *mlspb.Property) error

SaveNewListing saves the data collected into the in-memory data structure.

func (*MemoryDB) UpdateListing

func (m *MemoryDB) UpdateListing(p *mlspb.Property) error

UpdateListing appends new pricing information for an existing listing record.

type SqliteDB

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

DB creates the sqlite DB reference used to store data locally.

func NewSqliteDB

func NewSqliteDB(dbPath string) (*SqliteDB, error)

NewDBStorage creates an instance of the sqlite database used to store the data locally.

func (*SqliteDB) CreateStorage

func (d *SqliteDB) CreateStorage() error

CreateStorage for sqlite DB to create all the tables during module first use.

func (*SqliteDB) ReadListing

func (d *SqliteDB) ReadListing(mlsNumber string) (string, error)

func (*SqliteDB) ReadListings

func (d *SqliteDB) ReadListings() (*mlspb.Listings, error)

func (*SqliteDB) SaveNewListing

func (d *SqliteDB) SaveNewListing(p *mlspb.Property) error

SaveNewListing saves the data collected into the in-memory data structure.

func (*SqliteDB) UpdateListing

func (d *SqliteDB) UpdateListing(p *mlspb.Property) error

UpdateListing appends new pricing information for an existing listing record.

Jump to

Keyboard shortcuts

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