emsc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package emsc is the library behind the emsc command line: the HTTP client, request shaping, and the typed data models for the EMSC FDSN event web service at seismicportal.eu.

The Client sets a real User-Agent, paces requests so a busy session stays polite, and retries transient failures (429 and 5xx). Build your endpoint calls on top of it.

Index

Constants

View Source
const BaseURL = "https://www.seismicportal.eu/fdsnws/event/1"

BaseURL is the root every request is built from.

View Source
const Host = "www.seismicportal.eu"

Host is the site this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to the EMSC FDSN event web service over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with DefaultConfig.

func NewClientAt

func NewClientAt(baseURL string) *Client

NewClientAt returns a Client with a custom base URL, useful for tests.

func (*Client) GetCount

func (c *Client) GetCount(ctx context.Context, minMag float64) (int, error)

GetCount returns the total number of events matching minMag.

func (*Client) GetCountAt

func (c *Client) GetCountAt(ctx context.Context, baseURL string, minMag float64) (int, error)

GetCountAt is like GetCount but uses a custom base URL; useful for tests.

func (*Client) SearchEvents

func (c *Client) SearchEvents(ctx context.Context, minMag, maxMag float64, startTime, endTime string, limit, offset int) ([]*Event, error)

SearchEvents queries /query with the given filters and returns matching events.

func (*Client) SearchEventsAt

func (c *Client) SearchEventsAt(ctx context.Context, baseURL string, minMag, maxMag float64, startTime, endTime string, limit, offset int) ([]*Event, error)

SearchEventsAt is like SearchEvents but uses a custom base URL; useful for tests.

type Config

type Config struct {
	BaseURL   string
	Rate      time.Duration
	Retries   int
	Timeout   time.Duration
	UserAgent string
}

Config holds client settings.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults.

type Domain

type Domain struct{}

Domain is the EMSC driver. It carries no state; the per-run client is built by the factory Register hands kit.

func (Domain) Classify

func (Domain) Classify(input string) (string, string, error)

Classify turns a bare event id or EMSC URL into (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate returns the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type Event

type Event struct {
	ID            string  `json:"id"             kit:"id"` // = unid
	Time          string  `json:"time,omitempty"`
	Magnitude     float64 `json:"magnitude,omitempty"`
	MagType       string  `json:"mag_type,omitempty"`
	Depth         float64 `json:"depth_km,omitempty"`
	Latitude      float64 `json:"latitude,omitempty"`
	Longitude     float64 `json:"longitude,omitempty"`
	Region        string  `json:"region,omitempty"`
	Auth          string  `json:"auth,omitempty"`
	EventType     string  `json:"event_type,omitempty"`
	SourceCatalog string  `json:"source_catalog,omitempty"`
}

Event is one seismic event from the EMSC catalogue.

type EventCount

type EventCount struct {
	Total int `json:"total"`
}

EventCount is the output type for the count operation.

Jump to

Keyboard shortcuts

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