zkillredisqo

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2017 License: MIT Imports: 8 Imported by: 1

README

zkillredisqo

Build Status GoDoc

A small library for subscribing to zKillboard's RedisQ kill feed, written in Golang. The name originates from me being incredibly uncreative and combining "zKillboard", "RedisQ" and "Go".

Package zkillredisqo provides a lightweight library for interfacing with zKillboard's RedisQ service for receiving killmails in realtime.

The library allows for applications to wait for new kills using a channel. Errors are handed off to the calling app via a separate error channel.

Installation

go get -u github.com/MorpheusXAUT/zkillredisqo

Usage

A tiny sample app demonstrating the usage of zkillredisqo is included in examples/simple.go. In general, applications should create a Poller and receive messages from its Kills and Errors channels:

package main

import (
	"github.com/MorpheusXAUT/zkillredisqo"
	"log"
)

func main() {
	poller := zkillredisqo.NewPoller(nil)

	for {
		select {
		case kill := <-poller.Kills:
			log.Printf("%+v\n", kill)
			break
		case err := <-poller.Errors:
			log.Printf("*** ERROR: %v\n", err)
			break
		}
	}
}

Documentation

see https://godoc.org/github.com/MorpheusXAUT/zkillredisqo

Attribution

zKillboard

zKillboard's RedisQ is courtesy of zKillboard, legal information can be found here. Great thanks to Squizz Caphinator for preventing this service.

CCP

EVE Online and the EVE logo are the registered trademarks of CCP hf. All rights are reserved worldwide. All other trademarks are the property of their respective owners. EVE Online, the EVE logo, EVE and all associated logos and designs are the intellectual property of CCP hf. All artwork, screenshots, characters, vehicles, storylines, world facts or other recognizable features of the intellectual property relating to these trademarks are likewise the intellectual property of CCP hf. CCP hf. has granted permission to MorpheusXAUT to use EVE Online and all associated logos and designs for promotional and information purposes on its website but does not endorse, and is not in any way affiliated with, MorpheusXAUT. CCP is in no way responsible for the content on or functioning of this website, nor can it be liable for any damage arising from the use of this website.

License

MIT License

Documentation

Overview

Package zkillredisqo provides a lightweight library for interfacing with zKillboard's RedisQ service for receiving killmails in realtime. The library allows for applications to wait for new kills using a channel. Errors are handed off to the calling app via a separate error channel.

Index

Constants

View Source
const (
	// Version of zkillredisqo library
	Version = "1.0.2"
	// DefaultUserAgent defines a user agent to use for HTTP requests if separate one is specified by the user
	DefaultUserAgent = "zkillredisqo v" + Version + " - github.com/morpheusxaut/zkillredisqo"
	// ZKillRedisQURL defines the URL of zKillboard's RedisQ service
	ZKillRedisQURL = "https://redisq.zkillboard.com/listen.php"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Kill

type Kill struct {
	KillPackage `json:"package"`
}

Kill represents a kill as available on zKillboard

func (*Kill) IsNullKill

func (k *Kill) IsNullKill() bool

IsNullKill checks whether a kill is an empty "null" kill

type KillMail

type KillMail struct {
	ID            int                      `json:"killID"`
	Time          KillMailTime             `json:"killTime"`
	SolarSystem   KillMailCommonAttributes `json:"solarSystem"`
	Attackers     []KillMailAttacker       `json:"attackers"`
	AttackerCount int                      `json:"attackerCount"`
	Victim        KillMailVictim           `json:"victim"`
	War           struct {
		ID   int    `json:"id"`
		HRef string `json:"href"`
	} `json:"war"`
}

KillMail stores the actual information about an EVE killmail

type KillMailAttacker

type KillMailAttacker struct {
	Character      KillMailCommonAttributes `json:"character"`
	Corporation    KillMailCommonAttributes `json:"corporation"`
	Alliance       KillMailCommonAttributes `json:"alliance"`
	Faction        KillMailCommonAttributes `json:"faction"`
	Ship           KillMailCommonAttributes `json:"shipType"`
	Weapon         KillMailCommonAttributes `json:"weaponType"`
	DamageDone     int                      `json:"damageDone"`
	FinalBlow      bool                     `json:"finalBlow"`
	SecurityStatus float64                  `json:"securityStatus"`
}

KillMailAttacker represents information about a single attacking party

type KillMailCommonAttributes

type KillMailCommonAttributes struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	HRef string `json:"href"`
	Icon struct {
		HRef string `json:"href"`
	} `json:"icon"`
}

KillMailCommonAttributes represents information being reused for multiple parts of a killmail such as corporations, characters or ship types

type KillMailItem

type KillMailItem struct {
	Item              KillMailCommonAttributes `json:"itemType"`
	QuantityDropped   int                      `json:"quantityDropped"`
	QuantityDestroyed int                      `json:"quantityDestroyed"`
	Flag              int                      `json:"flag"`
	Singleton         int                      `json:"singleton"`
}

KillMailItem represents information about a single item included in a kill, either dropped or destroyed

type KillMailTime

type KillMailTime struct {
	time.Time
}

KillMailTime is used to allow for proper time parsing from JSON

func (*KillMailTime) UnmarshalJSON

func (t *KillMailTime) UnmarshalJSON(buf []byte) error

UnmarshalJSON tries to parse a timestamp provided by RedisQ to a Go time type

type KillMailVictim

type KillMailVictim struct {
	Character   KillMailCommonAttributes `json:"character"`
	Corporation KillMailCommonAttributes `json:"corporation"`
	Alliance    KillMailCommonAttributes `json:"alliance"`
	Faction     KillMailCommonAttributes `json:"faction"`
	Ship        KillMailCommonAttributes `json:"shipType"`
	DamageTaken int                      `json:"damageTaken"`
	Items       []KillMailItem           `json:"items"`
	Position    struct {
		X float64 `json:"x"`
		Y float64 `json:"y"`
		Z float64 `json:"z"`
	}
}

KillMailVictim represents information about the victim of a kill

type KillPackage

type KillPackage struct {
	ID         int                  `json:"killID"`
	KillMail   KillMail             `json:"killmail"`
	ZKillboard ZKillboardAttributes `json:"zkb"`
}

KillPackage represents the "package" layer kills are wrap in by RedisQ

type Poller

type Poller struct {
	// Kills will receive all parsed kills as they are received from zKillboard
	Kills chan *Kill
	// Errors will receive any error encountered while retrieving or parsing kills
	Errors chan error
	// contains filtered or unexported fields
}

Poller allows for polling of Kills from zKillboard's RedisQ service

func NewPoller

func NewPoller(client *http.Client) *Poller

NewPoller creates a new poller and starts the polling loop

func (*Poller) SetTimeToWait

func (p *Poller) SetTimeToWait(ttw int)

SetTimeToWait adjusts the timeToWait value passed to RedisQ

func (*Poller) SetUserAgent

func (p *Poller) SetUserAgent(ua string)

SetUserAgent allows for a custom user agent to be configured

func (*Poller) Stop

func (p *Poller) Stop()

Stop notifies the poller to stop its loop after the next iteration

func (*Poller) StopAndWait

func (p *Poller) StopAndWait()

StopAndWait notifies the poller to stop and waits for all requests to finish

func (*Poller) Wait

func (p *Poller) Wait()

Wait blocks until all requests have been finished

type ZKillboardAttributes

type ZKillboardAttributes struct {
	TotalValue float64 `json:"totalValue"`
	Points     int     `json:"points"`
	LocationID int     `json:"locationID"`
	Hash       string  `json:"hash"`
	HRef       string  `json:"href"`
}

ZKillboardAttributes stores additional information regarding the kill, provided by zKillboard

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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