audit

package
v0.0.0-...-ef5567d Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EXCHANGE_TABLE             = "exchanges"
	PARTNER_TABLE              = "partners"
	VEHICLE_TABLE              = "vehicles"
	LONG_TERM_STOP_VISIT_TABLE = "long_term_stop_visits"
)

Variables

View Source
var AraBigQuerySchemas = map[string]bigquery.Schema{
	"bqMessageSchema":            bqMessageSchema,
	"bqVehicleSchema":            bqVehicleSchema,
	"bqPartnerSchema":            bqPartnerSchema,
	"bqLongTermStopVisitsSchema": bqLongTermStopVisitsSchema,
}

Functions

func SetCurrentBigQuery

func SetCurrentBigQuery(slug string, bq BigQuery)

Types

type BigQuery

type BigQuery interface {
	state.Startable
	state.Stopable

	WriteEvent(event BigQueryEvent) error
}

func CurrentBigQuery

func CurrentBigQuery(slug string) BigQuery

func NewBigQuery

func NewBigQuery(dataset string) BigQuery

func NewNullBigQuery

func NewNullBigQuery() BigQuery

type BigQueryClient

type BigQueryClient struct {
	uuid.UUIDConsumer
	clock.ClockConsumer
	// contains filtered or unexported fields
}

*** Real BQ ***

func NewBigQueryClient

func NewBigQueryClient(dataset string) *BigQueryClient

func (*BigQueryClient) Start

func (bq *BigQueryClient) Start()

func (*BigQueryClient) Stop

func (bq *BigQueryClient) Stop()

func (*BigQueryClient) WriteEvent

func (bq *BigQueryClient) WriteEvent(e BigQueryEvent) error

type BigQueryEvent

type BigQueryEvent interface {
	EventType() string
	SetTimeStamp(time.Time)
	SetUUID(string)
}

type BigQueryLongTermStopVisitEvent

type BigQueryLongTermStopVisitEvent struct {
	UUID      string    `bigquery:"uuid"`
	Timestamp time.Time `bigquery:"timestamp"`

	StopVisitUUID      string                 `bigquery:"stop_visit_uuid"`
	AimedDepartureTime bigquery.NullTimestamp `bigquery:"aimed_departure_time"`
	AimedArrivalTime   bigquery.NullTimestamp `bigquery:"aimed_arrival_time"`

	ExpectedDepartureTime bigquery.NullTimestamp `bigquery:"expected_departure_time"`
	ExpectedArrivalTime   bigquery.NullTimestamp `bigquery:"expected_arrival_time"`

	ActualDepartureTime bigquery.NullTimestamp `bigquery:"actual_departure_time"`
	ActualArrivalTime   bigquery.NullTimestamp `bigquery:"actual_arrival_time"`

	DepartureStatus string `bigquery:"departure_status"`
	ArrivalStatus   string `bigquery:"arrival_status"`

	StopAreaName        string `bigquery:"stop_area_name"`
	StopAreaCodes       []Code `bigquery:"stop_area_codes"`
	StopAreaCoordinates string `bigquery:"stop_area_coordinates"`

	LineName      string `bigquery:"line_name"`
	LineNumber    string `bigquery:"line_number"`
	TransportMode string `bigquery:"transport_mode"`
	LineCodes     []Code `bigquery:"line_codes"`

	VehicleJourneyDirectionType   string `bigquery:"vehicle_journey_direction_type"`
	VehicleJourneyOriginName      string `bigquery:"vehicle_journey_origin_name"`
	VehicleJourneyDestinationName string `bigquery:"vehicle_journey_destination_name"`
	VehicleJourneyCodes           []Code `bigquery:"vehicle_journey_codes"`
	VehicleDriverRef              string `bigquery:"vehicle_driver_ref"`
	VehicleOccupancy              string `bigquery:"vehicle_occupancy"`
}

func (*BigQueryLongTermStopVisitEvent) EventType

func (bq *BigQueryLongTermStopVisitEvent) EventType() string

func (*BigQueryLongTermStopVisitEvent) SetTimeStamp

func (bq *BigQueryLongTermStopVisitEvent) SetTimeStamp(t time.Time)

func (*BigQueryLongTermStopVisitEvent) SetUUID

func (bq *BigQueryLongTermStopVisitEvent) SetUUID(u string)

type BigQueryManager

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

type BigQueryMessage

type BigQueryMessage struct {
	UUID                    string              `bigquery:"uuid"`
	Timestamp               time.Time           `bigquery:"timestamp"`
	IPAddress               string              `bigquery:"ip_address"`
	Protocol                string              `bigquery:"protocol"`  // "siri", "siri-lite", "gtfs", "push"
	Type                    BigQueryMessageType `bigquery:"type"`      // "siri-checkstatus", "gtfs-trip-update", …
	Direction               string              `bigquery:"direction"` // "sent" (by Ara), "received" (by Ara)
	Partner                 string              `bigquery:"partner"`   // partner slug
	Status                  string              `bigquery:"status"`    // "OK", "Error"
	ErrorDetails            string              `bigquery:"error_details"`
	RequestRawMessage       string              `bigquery:"request_raw_message"`  // XML or JSON for GTFS-RT
	ResponseRawMessage      string              `bigquery:"response_raw_message"` // XML or JSON for GTFS-RT
	RequestIdentifier       string              `bigquery:"request_identifier"`
	ResponseIdentifier      string              `bigquery:"response_identifier"`
	RequestSize             int64               `bigquery:"request_size"`
	ResponseSize            int64               `bigquery:"response_size"`
	ProcessingTime          float64             `bigquery:"processing_time"`          // in seconds
	SubscriptionIdentifiers []string            `bigquery:"subscription_identifiers"` // array of ids
	StopAreas               []string            `bigquery:"stop_areas"`               // array of code values
	Lines                   []string            `bigquery:"lines"`                    // array of code values
	Vehicles                []string            `bigquery:"vehicles"`
	VehicleJourneys         []string            `bigquery:"vehicle_journeys"` // array of code values
}

func (*BigQueryMessage) EventType

func (bq *BigQueryMessage) EventType() string

func (*BigQueryMessage) SetTimeStamp

func (bq *BigQueryMessage) SetTimeStamp(t time.Time)

func (*BigQueryMessage) SetUUID

func (bq *BigQueryMessage) SetUUID(u string)

type BigQueryMessageType

type BigQueryMessageType string
const (
	BQ_MESSAGE                    = "message"
	BQ_VEHICLE_EVENT              = "vehicle"
	BQ_PARTNER_EVENT              = "partner"
	BQ_LONG_TERM_STOP_VISIT_EVENT = "long_term_stop_visit"

	CHECK_STATUS_REQUEST BigQueryMessageType = "CheckStatusRequest"

	NOTIFY_ESTIMATED_TIMETABLE  BigQueryMessageType = "NotifyEstimatedTimetable"
	NOTIFY_GENERAL_MESSAGE      BigQueryMessageType = "NotifyGeneralMessage"
	NOTIFY_PRODUCTION_TIMETABLE BigQueryMessageType = "NotifyProductionTimetable"
	NOTIFY_SITUATION_EXCHANGE   BigQueryMessageType = "NotifySituationExchange"
	NOTIFY_STOP_MONITORING      BigQueryMessageType = "NotifyStopMonitoring"
	NOTIFY_VEHICLE_MONITORING   BigQueryMessageType = "NotifyVehicleMonitoring"

	DELETE_SUBSCRIPTION_REQUEST    BigQueryMessageType = "DeleteSubscriptionRequest"
	NOTIFY_SUBSCRIPTION_TERMINATED BigQueryMessageType = "NotifySubscriptionTerminated"

	ESTIMATED_TIMETABLE_REQUEST   BigQueryMessageType = "EstimatedTimetableRequest"
	GENERAL_MESSAGE_REQUEST       BigQueryMessageType = "GeneralMessageRequest"
	LINES_DISCOVERY_REQUEST       BigQueryMessageType = "LinesDiscoveryRequest"
	SIRI_SERVICE_REQUEST          BigQueryMessageType = "SiriServiceRequest"
	SITUATION_EXCHANGE_REQUEST    BigQueryMessageType = "SituationExchangeRequest"
	STOP_MONITORING_REQUEST       BigQueryMessageType = "StopMonitoringRequest"
	STOP_POINTS_DISCOVERY_REQUEST BigQueryMessageType = "StopPointsDiscoveryRequest"
	VEHICLE_MONITORING_REQUEST    BigQueryMessageType = "VehicleMonitoringRequest"

	GTFS_TRIP_UPDATES_VEHICLE_POSITION_SERVICE_ALERTS BigQueryMessageType = "trip-updates,vehicle-position,service-alerts"
	GTFS_TRIP_UPDATES                                 BigQueryMessageType = "trip-updates"
	GTFS_VEHICLE_POSITION                             BigQueryMessageType = "vehicle-position"
	GTFS_REQUEST                                      BigQueryMessageType = "GtfsRequest"

	SUBSCRIPTION_TERMINATED_NOTIFICATION BigQueryMessageType = "SubscriptionTerminatedNotification"

	ESTIMATED_TIMETABLE_SUBSCRIPTION_REQUEST  BigQueryMessageType = "EstimatedTimetableSubscriptionRequest"
	GENERAL_MESSAGE_SUBSCRIPTION_REQUEST      BigQueryMessageType = "GeneralMessageSubscriptionRequest"
	PRODUCTION_TIMETABLE_SUBSCRIPTION_REQUEST BigQueryMessageType = "ProductionTimetableSubscriptionRequest"
	STOP_MONITORING_SUBSCRIPTION_REQUEST      BigQueryMessageType = "StopMonitoringSubscriptionRequest"
	VEHICLE_MONITORING_SUBSCRIPTION_REQUEST   BigQueryMessageType = "VehicleMonitoringSubscriptionRequest"
	SITUATION_EXCHANGE_SUBSCRIPTION_REQUEST   BigQueryMessageType = "SituationExchangeSubscriptionRequest"

	PUSH_NOTIFICATION BigQueryMessageType = "push-notification"
)

type BigQueryPartnerEvent

type BigQueryPartnerEvent struct {
	UUID                     string         `bigquery:"uuid"`
	Timestamp                time.Time      `bigquery:"timestamp"`
	Slug                     string         `bigquery:"slug"`
	PartnerUUID              string         `bigquery:"partner_uuid"`
	PreviousStatus           string         `bigquery:"previous_status"`
	PreviousServiceStartedAt civil.DateTime `bigquery:"previous_service_started_at"`
	NewStatus                string         `bigquery:"new_status"`
	NewServiceStartedAt      civil.DateTime `bigquery:"new_service_started_at"`
}

func (*BigQueryPartnerEvent) EventType

func (bq *BigQueryPartnerEvent) EventType() string

func (*BigQueryPartnerEvent) SetTimeStamp

func (bq *BigQueryPartnerEvent) SetTimeStamp(t time.Time)

func (*BigQueryPartnerEvent) SetUUID

func (bq *BigQueryPartnerEvent) SetUUID(u string)

type BigQueryVehicleEvent

type BigQueryVehicleEvent struct {
	UUID           string         `bigquery:"uuid"`
	Timestamp      time.Time      `bigquery:"timestamp"`
	ID             string         `bigquery:"id"`
	Codes          []string       `bigquery:"codes"`
	Longitude      float64        `bigquery:"longitude"`
	Latitude       float64        `bigquery:"latitude"`
	Bearing        float64        `bigquery:"bearing"`
	RecordedAtTime civil.DateTime `bigquery:"recorded_at_time"`
}

func (*BigQueryVehicleEvent) EventType

func (bq *BigQueryVehicleEvent) EventType() string

func (*BigQueryVehicleEvent) SetTimeStamp

func (bq *BigQueryVehicleEvent) SetTimeStamp(t time.Time)

func (*BigQueryVehicleEvent) SetUUID

func (bq *BigQueryVehicleEvent) SetUUID(u string)

type Code

type Code struct {
	Kind  string `bigquery:"kind"`
	Value string `bigquery:"value"`
}

type FakeBigQuery

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

*** Test Memory Structure ***

func NewFakeBigQuery

func NewFakeBigQuery() *FakeBigQuery

func (*FakeBigQuery) LongTermStopVisitEvents

func (bq *FakeBigQuery) LongTermStopVisitEvents() []*BigQueryLongTermStopVisitEvent

func (*FakeBigQuery) Messages

func (bq *FakeBigQuery) Messages() []*BigQueryMessage

func (*FakeBigQuery) PartnerEvents

func (bq *FakeBigQuery) PartnerEvents() []*BigQueryPartnerEvent

func (*FakeBigQuery) Start

func (bq *FakeBigQuery) Start()

func (*FakeBigQuery) Stop

func (bq *FakeBigQuery) Stop()

func (*FakeBigQuery) VehicleEvents

func (bq *FakeBigQuery) VehicleEvents() []*BigQueryVehicleEvent

func (*FakeBigQuery) WriteEvent

func (bq *FakeBigQuery) WriteEvent(e BigQueryEvent) error

type NullBigQuery

type NullBigQuery struct{}

*** Null struct to disable BQ by default ***

func (*NullBigQuery) Start

func (bq *NullBigQuery) Start()

func (*NullBigQuery) Stop

func (bq *NullBigQuery) Stop()

func (*NullBigQuery) WriteEvent

func (bq *NullBigQuery) WriteEvent(_ BigQueryEvent) error

type TestBigQuery

type TestBigQuery struct {
	clock.ClockConsumer
	// contains filtered or unexported fields
}

func NewTestBigQuery

func NewTestBigQuery(dataset string) *TestBigQuery

func (*TestBigQuery) Start

func (bq *TestBigQuery) Start()

func (*TestBigQuery) Stop

func (bq *TestBigQuery) Stop()

func (*TestBigQuery) WriteEvent

func (bq *TestBigQuery) WriteEvent(e BigQueryEvent) error

type TestBigQueryMessage

type TestBigQueryMessage struct {
	*BigQueryMessage
	Dataset string
}

Jump to

Keyboard shortcuts

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