trace

package
v0.0.0-...-1f0e2f3 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const EXPIRATION = time.Minute // Cache expiration duration for calling external API response
View Source
const HOST_IP_TO_BYPASS_GFW = "168.95.246.1:443"

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding struct {
	Source string `form:"source" json:"source" xml:"source" binding:"required"`
}

type CEA_DASE

type CEA_DASE struct {
	DataSourceCache
}

func (*CEA_DASE) Fetch

func (c *CEA_DASE) Fetch() ([]byte, error)

func (*CEA_DASE) Format

func (c *CEA_DASE) Format(latitude, longitude float64, data map[string]any) ([]Event, error)

func (*CEA_DASE) List

func (c *CEA_DASE) List(latitude, longitude float64) ([]Event, error)

func (*CEA_DASE) Parse

func (c *CEA_DASE) Parse(data []byte) (map[string]any, error)

func (*CEA_DASE) Property

func (c *CEA_DASE) Property() string

type CEIC

type CEIC struct {
	DataSourceCache
}

func (*CEIC) Fetch

func (c *CEIC) Fetch() ([]byte, error)

func (*CEIC) Format

func (c *CEIC) Format(latitude, longitude float64, data map[string]any) ([]Event, error)

func (*CEIC) List

func (c *CEIC) List(latitude, longitude float64) ([]Event, error)

func (*CEIC) Parse

func (c *CEIC) Parse(data []byte) (map[string]any, error)

func (*CEIC) Property

func (c *CEIC) Property() string

type CWA

type CWA struct {
	DataSourceCache
}

func (*CWA) Fetch

func (c *CWA) Fetch() ([]byte, error)

func (*CWA) Format

func (c *CWA) Format(latitude, longitude float64, data map[string]any) ([]Event, error)

func (*CWA) List

func (c *CWA) List(latitude, longitude float64) ([]Event, error)

func (*CWA) Parse

func (c *CWA) Parse(data []byte) (map[string]any, error)

func (*CWA) Property

func (c *CWA) Property() string

type DataSource

type DataSource interface {
	Property() string
	Fetch() ([]byte, error)
	Parse([]byte) (map[string]any, error)
	List(latitude, longitude float64) ([]Event, error)
	Format(float64, float64, map[string]any) ([]Event, error)
}

type DataSourceCache

type DataSourceCache struct {
	Time  time.Time
	Cache []byte
}

type Event

type Event struct {
	Verfied    bool       `json:"verfied"`
	Timestamp  int64      `json:"timestamp"`
	Event      string     `json:"event"`
	Region     string     `json:"region"`
	Depth      float64    `json:"depth"`
	Latitude   float64    `json:"latitude"`
	Longitude  float64    `json:"longitude"`
	Distance   float64    `json:"distance"`
	Magnitude  float64    `json:"magnitude"`
	Estimation estimation `json:"estimation"`
}

type HKO

type HKO struct {
	DataSourceCache
}

func (*HKO) Fetch

func (h *HKO) Fetch() ([]byte, error)

func (*HKO) Format

func (h *HKO) Format(latitude, longitude float64, data map[string]any) ([]Event, error)

func (*HKO) List

func (h *HKO) List(latitude, longitude float64) ([]Event, error)

func (*HKO) Parse

func (h *HKO) Parse(data []byte) (map[string]any, error)

func (*HKO) Property

func (h *HKO) Property() string

type INGV

type INGV struct {
	DataSourceCache
}

func (*INGV) Fetch

func (c *INGV) Fetch() ([]byte, error)

func (*INGV) Format

func (c *INGV) Format(latitude, longitude float64, data map[string]any) ([]Event, error)

func (*INGV) List

func (c *INGV) List(latitude, longitude float64) ([]Event, error)

func (*INGV) Parse

func (c *INGV) Parse(data []byte) (map[string]any, error)

func (*INGV) Property

func (c *INGV) Property() string

type JMA

type JMA struct {
	DataSourceCache
}

func (*JMA) Fetch

func (j *JMA) Fetch() ([]byte, error)

func (*JMA) Format

func (j *JMA) Format(latitude, longitude float64, data map[string]any) ([]Event, error)

func (*JMA) List

func (j *JMA) List(latitude, longitude float64) ([]Event, error)

func (*JMA) Parse

func (j *JMA) Parse(data []byte) (map[string]any, error)

func (*JMA) Property

func (j *JMA) Property() string

type KMA

type KMA struct {
	DataSourceCache
}

func (*KMA) Fetch

func (k *KMA) Fetch() ([]byte, error)

func (*KMA) Format

func (k *KMA) Format(latitude, longitude float64, data map[string]any) ([]Event, error)

func (*KMA) List

func (k *KMA) List(latitude, longitude float64) ([]Event, error)

func (*KMA) Parse

func (k *KMA) Parse(data []byte) (map[string]any, error)

func (*KMA) Property

func (k *KMA) Property() string

type SCEA_B

type SCEA_B struct {
	DataSourceCache
}

func (*SCEA_B) Fetch

func (s *SCEA_B) Fetch() ([]byte, error)

func (*SCEA_B) Format

func (s *SCEA_B) Format(latitude, longitude float64, data map[string]any) ([]Event, error)

func (*SCEA_B) List

func (s *SCEA_B) List(latitude, longitude float64) ([]Event, error)

func (*SCEA_B) Parse

func (s *SCEA_B) Parse(data []byte) (map[string]any, error)

func (*SCEA_B) Property

func (s *SCEA_B) Property() string

type SCEA_E

type SCEA_E struct {
	SCEA_B
	DataSourceCache
}

func (*SCEA_E) Fetch

func (s *SCEA_E) Fetch() ([]byte, error)

func (*SCEA_E) Format

func (s *SCEA_E) Format(latitude, longitude float64, data map[string]any) ([]Event, error)

func (*SCEA_E) List

func (s *SCEA_E) List(latitude, longitude float64) ([]Event, error)

func (*SCEA_E) Property

func (s *SCEA_E) Property() string

type Trace

type Trace struct{}

func (*Trace) RegisterModule

func (t *Trace) RegisterModule(rg *gin.RouterGroup, options *app.ServerOptions)

@Summary AnyShake Observer event trace @Description Get list of earthquake events data source and earthquake events from specified data source @Router /trace [post] @Accept application/x-www-form-urlencoded @Produce application/json @Param source formData string true "Use `show` to get available sources first, then choose one and request again to get events" @Failure 400 {object} response.HttpResponse "Failed to read earthquake event list due to invalid data source" @Failure 500 {object} response.HttpResponse "Failed to read earthquake event list due to failed to read data source" @Success 200 {object} response.HttpResponse{data=[]Event} "Successfully read the list of earthquake events"

type USGS

type USGS struct {
	DataSourceCache
}

func (*USGS) Fetch

func (u *USGS) Fetch() ([]byte, error)

func (*USGS) Format

func (u *USGS) Format(latitude, longitude float64, data map[string]any) ([]Event, error)

func (*USGS) List

func (u *USGS) List(latitude, longitude float64) ([]Event, error)

func (*USGS) Parse

func (u *USGS) Parse(data []byte) (map[string]any, error)

func (*USGS) Property

func (u *USGS) Property() string

Jump to

Keyboard shortcuts

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