Documentation
¶
Overview ¶
Package tseventserver provides the core types and interfaces for economic calendar events, including an HTTP‑based ingestion and retrieval server, and pluggable storage backends (SQLite and Google Cloud Firestore).
Key types ¶
- [Event] represents a single economic release (e.g., GDP, CPI) with its actual, estimate, previous, and impact fields.
- EventRepository is the storage interface implemented by [SQLiteEventRepository] and FirestoreEventRepository.
- EventServer exposes authenticated HTTP endpoints: /events/ingest (POST) and /events/retrieve (GET).
Typical usage ¶
Create a repository, then start the server:
repo, err := tseventserver.NewSQLiteEventRepository("events.db")
// ... error handling ...
defer repo.Close()
api := tseventserver.NewEventServer(repo, "your-api-token")
http.ListenAndServe(":8080", api)
Copyright (c) 2026 thorsphere. All Rights Reserved. Use is governed with GNU Affero General Public License v3.0 that can be found in the LICENSE file.
Copyright (c) 2026 thorsphere. All Rights Reserved. Use is governed with GNU Affero General Public License v3.0 that can be found in the LICENSE file.
Copyright (c) 2026 thorsphere. All Rights Reserved. Use is governed with GNU Affero General Public License v3.0 that can be found in the LICENSE file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventRepository ¶
type EventRepository interface {
Store(ctx context.Context, event *tstrading.Event) error // Store saves a new economic event to the repository. If it already exists, it should update the existing record.
GetByPeriod(ctx context.Context, period *tstrading.Period) ([]tstrading.Event, error) // GetByPeriod retrieves economic events that occurred within a specified time period.
Close() error // Close releases any resources held by the repository, such as database connections.
}
EventRepository defines the interface for managing economic events in a storage system.
type EventServer ¶
type EventServer struct {
// contains filtered or unexported fields
}
EventServer is a struct that represents the event server responsible for handling event ingestion.
func NewEventServer ¶
func NewEventServer(repo EventRepository, tok string) *EventServer
NewEventServer creates a new instance of EventServer with the provided EventRepository.
func (*EventServer) ServeHTTP ¶
func (s *EventServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP makes EventServer implement the http.Handler interface, allowing it to easily route incoming requests to its internal multiplexer. This handles HTTP requests natively and is especially useful for testing.
type FirestoreEventRepository ¶
type FirestoreEventRepository struct {
// contains filtered or unexported fields
}
FirestoreEventRepository is an implementation of the EventRepository interface that uses Google Cloud Firestore as the storage backend.
func NewFirestoreEventRepository ¶
func NewFirestoreEventRepository(ctx context.Context, projectID string) (*FirestoreEventRepository, error)
NewFirestoreEventRepository creates a new instance of FirestoreEventRepository with the provided Google Cloud project ID.
func (*FirestoreEventRepository) Close ¶
func (r *FirestoreEventRepository) Close() error
Close closes the connection to the Firestore database and releases any associated resources.
func (*FirestoreEventRepository) GetByPeriod ¶
func (r *FirestoreEventRepository) GetByPeriod(ctx context.Context, period *tstrading.Period) ([]tstrading.Event, error)
GetByPeriod retrieves economic events that occurred within a specified time period.