redisq

package
v0.0.0-...-d5df94c Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2017 License: MIT Imports: 5 Imported by: 3

README

evelib/redisq

This package implements a client to ZKillboard's RedisQ API for retrieving EVE Online killmails in near-real time as they are posted to ZKillboard.

PLEASE NOTE

Due to he nature of RedisQ, having more than one RedisQ client running simultaneously (in the same program or another) will ultimately disrupt one another. This means that for ever killmail consumed by one client, another client will not receive the same killmail.

Avoiding this issue: You can specify a Queue ID in redisq.Options that uniquely identifies your RedisQ client.

Documentation

Index

Constants

View Source
const (
	// DefaultAddr is the default address the RedisQ client queries.
	DefaultAddr = "https://redisq.zkillboard.com/listen.php"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attacker

type Attacker struct {
	CharacterID    int     `json:"character_id"`
	CorporationID  int     `json:"corporation_id"`
	AllianceID     int     `json:"alliance_id"`
	ShipTypeID     int     `json:"ship_type_id"`
	WeaponTypeID   int     `json:"weapon_type_id"`
	DamageDone     int     `json:"damage_done"`
	FinalBlow      bool    `json:"final_blow"`
	SecurityStatus float32 `json:"security_status"`
}

Attacker in a killmail

type Client

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

Client to listen to ZKillboards RedisQ service for new Killmails recieved from EVE Online.

func NewClient

func NewClient(opts *Options) (client *Client)

NewClient takes an option parameter, which may be nil, and configures and returns a new client.

func (*Client) AddChan

func (client *Client) AddChan(reciever RecieverChan)

AddChan adds a channel to the client which will be sent all future Killmails that are recieved.

func (*Client) AddFunc

func (client *Client) AddFunc(reciever RecieverFunc)

AddFunc adds a function to the client which will be called andpassed all future killmails that are recieved.

func (*Client) Close

func (client *Client) Close()

Close the client's connection to RedisQ.

func (*Client) Listen

func (client *Client) Listen()

Listen starts recieving and distributing killmails to added recievers.

func (*Client) SetErrorChannel

func (client *Client) SetErrorChannel(errchan chan error)

SetErrorChannel accepts a channel of type error to which errors encountered are sent by the client.

type Item

type Item struct {
	ItemTypeID        int `json:"item_type_id"`
	Flag              int `json:"flag"`
	Singleton         int `json:"singleton"`
	QuantityDropped   int `json:"quantity_dropped"`
	QuantityDestroyed int `json:"quantity_destroyed"`
}

Item dropped/destroyed in a killmail

type Killmail

type Killmail struct {
	ID            int        `json:"killmail_id"`
	Hash          string     `json:"killmail_hash"`
	SolarSystemID int        `json:"solar_system_id"`
	Timestamp     time.Time  `json:"killmail_time"`
	Victim        Victim     `json:"victim"`
	Attackers     []Attacker `json:"attackers"`
	Zkb           Zkb        `json:"zkb"`
}

Killmail from a kill

type Options

type Options struct {
	// Addr of the target RedisQ service. When left empty, defaults to DefaultAddr.
	Addr string
	// QueueID to identify the client. Set this to a unique value if you have
	// multiple services hitting the RedisQ API at the same time.
	//
	// NOTE: Save this value somewhere if you don't want to miss killmails!
	QueueID string
}

Options is used to configure the RedisQ Client.

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions for the package client.

type Payload

type Payload struct {
	KillID   int      `json:"killID"`
	Killmail Killmail `json:"killmail"`
	Zkb      struct {
		LocationID int     `json:"locationID"`
		Hash       string  `json:"hash"`
		TotalValue float32 `json:"totalValue"`
		Points     int     `json:"points"`
		Href       string  `json:"href"`
	}
}

Payload is the json encoded response containing the killmail that is returned as well as some meta information.

type RecieverChan

type RecieverChan chan Payload

RecieverChan is a channel that may recive a payload containing information pertaining to a killmail.

type RecieverFunc

type RecieverFunc func(Payload)

RecieverFunc is a function that may called and passed a new Payload model as the parameter.

type Victim

type Victim struct {
	CharacterID   int    `json:"character_id"`
	CorporationID int    `json:"corporation_id"`
	AllianceID    int    `json:"alliance_id"`
	ShipTypeID    int    `json:"ship_type_id"`
	DamageTaken   int    `json:"damage_taken"`
	Items         []Item `json:"items"`
	Position      struct {
		X float64 `json:"x"`
		Y float64 `json:"y"`
		Z float64 `json:"z"`
	} `json:"position"`
}

Victim in a killmail

type Zkb

type Zkb struct {
	Hash        string  `json:"hash"`
	FittedValue float32 `json:"fittedValue"`
	TotalValue  float32 `json:"totalValue"`
	Points      int     `json:"points"`
	NPC         bool    `json:"npc"`
	Solo        bool    `json:"solo"`
	AWOX        bool    `json:"awox"`
	Href        string  `json:"href"`
}

Zkb is the meta data returned from ZKillboard.

Jump to

Keyboard shortcuts

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