streams

package
v0.0.0-...-039e935 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultURL is the URL of the Wikimedia EventStreams service (sans any stream endpoints)
	DefaultURL string = "https://stream.wikimedia.org/v2/stream"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL    string
	Predicates map[string]interface{}
	Since      string
	// contains filtered or unexported fields
}

Client is used to subscribe to the Wikimedia EventStreams service

func NewClient

func NewClient() *Client

NewClient returns an initialized Client

func (*Client) LastTimestamp

func (client *Client) LastTimestamp() string

LastTimestamp returns the ISO8601 formatted timestamp of the last event received.

func (*Client) Match

func (client *Client) Match(attribute string, value interface{}) *Client

Match adds a new predicate. Predicates are used to used to establish a match based on the JSON attribute name. Events match only when all predicates do.

func (*Client) RecentChanges

func (client *Client) RecentChanges(handler func(evt RecentChangeEvent)) error

RecentChanges subscribes to the recent changes feed. The handler is invoked with a RecentChangeEvent once for every matching event received.

type RecentChangeEvent

type RecentChangeEvent struct {
	ID        int    `json:"id"`
	Meta      meta   `json:"meta"`
	Type      string `json:"type"`
	Namespace int    `json:"namespace"`
	Title     string `json:"title"`
	Comment   string `json:"comment"`
	Timestamp int    `json:"timestamp"`
	User      string `json:"user"`
	Bot       bool   `json:"bot"`
	Minor     bool   `json:"minor"`
	Patrolled bool   `json:"patrolled"`
	Length    struct {
		Old int
		New int
	}
	Revision struct {
		Old int
		New int
	}
	ServerURL        string `json:"server_url"`
	ServerName       string `json:"server_name"`
	ServerScriptPath string `json:"server_script_path"`
	Wiki             string `json:"wiki"`
	ParsedComment    string `json:"parsedcomment"`
	// contains filtered or unexported fields
}

RecentChangeEvent corresponds to the JSON event objects returned by the recent changes stream (see: https://github.com/wikimedia/mediawiki-event-schemas/blob/master/jsonschema/mediawiki/recentchange/1.0.0.yaml).

Jump to

Keyboard shortcuts

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