Documentation
¶
Index ¶
- Constants
- Variables
- func GetRawsPG(db *sql.DB, cancel <-chan struct{}, observatories []string, ...) (chan *RecordIn, int)
- func GetTimeseriesPG(db *sql.DB, observatories []string, fields []string, x0, x1 int64) (map[string]map[string]Timeseries, error)
- func PutRawsBulkPG(db *sql.DB, cancel chan struct{}, recs chan *RecordIn, nrecs int)
- type Cache
- type Chain
- type ClientStat
- type DataArr
- func (da DataArr) Compress(npoints int) (DataArr, error)
- func (da DataArr) Deduplicate(npoints int) (DataArr, error)
- func (da DataArr) Len() int
- func (da DataArr) Less(i, j int) bool
- func (a DataArr) MergeFromRight(b DataArr) DataArr
- func (da DataArr) Rebin(npoints int) (DataArr, error)
- func (da DataArr) Swap(i, j int)
- func (da DataArr) ToTimeseries() (ts Timeseries)
- type DataStore
- func (ds DataStore) GetDataHistories(observatories []string, fields []string, startTime *time.Time, ...) (map[string]map[string]DataArr, error)
- func (ds DataStore) PutRecord(facility, clientname, clientip, version string, trecv int64, ...) (string, error)
- func (ds *DataStore) RawGetHandle(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (ds *DataStore) RawPostHandle(uc *userapi.UserCache) httprouter.Handle
- func (ds DataStore) Replayer(replay replayapi.Job)
- func (ds *DataStore) SnapshotGetHandle(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (ds DataStore) StartWatching(dir string, nstart int)
- func (ds *DataStore) TimeseriesDownloadHandle(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (ds *DataStore) TimeseriesHandle(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (ds *DataStore) TimeseriesPatchHandle(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- type Dataflat
- type Header
- type HeaderArr
- type MessagePoint
- type MsgCache
- type Node
- type RecordIn
- type StatusRecord
- type Timeseries
- type VexfileInfo
Constants ¶
const TS_MERGE_N_RECORDS_MAX = 10000000
number of big-record input records, affect memory usage
const TS_N_WORKERS_MAX = 10
number of workers per observatory
const TS_ROWLENGTH_MAX = 2000
const TS_ROWLENGTH_MIN = 1000
number of data points in a full timeseries row Changing these values requires rebuilding the timeseries table!
const TS_UPDATE_SINCE_MAX = 600 * time.Second
max duration between updateTimeseries calls
Variables ¶
var MSGCACHE_FIELDS = [2]string{"status", "weather"}
Message
avoid using a map to support concurrent access to the cache
Functions ¶
func GetRawsPG ¶
func GetRawsPG(db *sql.DB, cancel <-chan struct{}, observatories []string, startTime, endTime *time.Time, idFrom uint64) (chan *RecordIn, int)
GetRawsPG selects records from the raw table with (id > idFrom) or (tdata in a time window), unmarshals the containing records, and returns a result channel from which these can be received by a concurrent goproc.
func GetTimeseriesPG ¶
func GetTimeseriesPG(db *sql.DB, observatories []string, fields []string, x0, x1 int64) (map[string]map[string]Timeseries, error)
GetTimeseriesPG retrieves the timeseries for a list of observatories and fields.
func PutRawsBulkPG ¶
PutRawsBulkPG receives records from the recs channel and inserts them into the rawdata table after doing some cleanup:
- It translates varnames to the new "_" delimiter from the old ":"
- It skips data arrays that contain the UFT-8 "replacement character" as this is not recognized as valid UFT-8 in postgres
- It skips empty (heartbeat) records
Types ¶
type ClientStat ¶
type DataArr ¶
type DataArr [][2]interface{}
func (DataArr) Deduplicate ¶
drop some of the repeating values
func (DataArr) MergeFromRight ¶
Merge b into a, growing a to the required capacity if necessary This function is the DataArr analog to Timeseries.MergeFromRight.
func (DataArr) ToTimeseries ¶
func (da DataArr) ToTimeseries() (ts Timeseries)
convert DataArr to Timeseries
type DataStore ¶
type DataStore struct {
// contains filtered or unexported fields
}
func NewDataStore ¶
func (DataStore) GetDataHistories ¶
func (*DataStore) RawGetHandle ¶
func (ds *DataStore) RawGetHandle(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*DataStore) RawPostHandle ¶
func (ds *DataStore) RawPostHandle(uc *userapi.UserCache) httprouter.Handle
func (*DataStore) SnapshotGetHandle ¶
func (ds *DataStore) SnapshotGetHandle(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (DataStore) StartWatching ¶
StartWatching uses inotify to see new files appear and disappear and schedules a file with a short delay to allow for file I/O operations to finish. The event handler catches inotify errors and restarts the watcher if necessary.
func (*DataStore) TimeseriesDownloadHandle ¶
func (ds *DataStore) TimeseriesDownloadHandle(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*DataStore) TimeseriesHandle ¶
func (ds *DataStore) TimeseriesHandle(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*DataStore) TimeseriesPatchHandle ¶
func (ds *DataStore) TimeseriesPatchHandle(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
SnapshotPatchHandle triggers updating the timeseries table
type Header ¶
type Header struct { RecvTime time.Time `json:"recvTime,omitempty" bson:"recvTime,omitempty"` Username string `json:"username,omitempty" bson:",omitempty"` Facility string `json:"facility,omitempty" bson:",omitempty"` ClientVersion string `json:"clientVersion,omitempty" bson:"clientVersion,omitempty"` // contains filtered or unexported fields }
type MessagePoint ¶
type MsgCache ¶
type MsgCache [2]MessagePoint // see MSGCACHE_FIELDS
type RecordIn ¶
type StatusRecord ¶
type StatusRecord struct { Clients map[string]ClientStat `json:"clients,omitempty" bson:"lastUpdate"` Data Dataflat `json:"data,omitempty"` Messages map[string]MessagePoint `json:"messages,omitempty"` }
type Timeseries ¶
type Timeseries struct {
// contains filtered or unexported fields
}
Timeseries contains the x and y coordinates of the data points in a timeseries in two separate arrays.
func (Timeseries) MergeFromRight ¶
func (a Timeseries) MergeFromRight(b Timeseries) (ts Timeseries)
Merge b into a, growing a to the required capacity if necessary This function is the Timeseries analog of DataArr.MergeFromRight.