wikimedia

module
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

README

eevans Apache V2 License Documentation

Wikimedia SDK for Go

Golang packages for working with Wikimedia services.

streams package

The streams package provides high-level access to the Wikimedia EventStreams service.

Quick start

To install:

$ go get github.com/eevans/wikimedia/streams

To test:

$ make test
Example
package main

import (
    "fmt"

    "github.com/eevans/wikimedia/streams"
)

func main() {
    client := streams.NewClient()
    
    client.RecentChanges(func(event streams.RecentChangeEvent) {
        fmt.Printf("Change event captured!\n")
        fmt.Printf("  Title .........: %s\n", event.Title)
        fmt.Printf("  Server name ...: %s\n", event.ServerName)
        fmt.Printf("  Wiki ..........: %s\n", event.Wiki)
        fmt.Printf("  Namespace .....: %d\n", event.Namespace)
    })
}

Additionally, you can filter the list of events to those matching a set of predicates.

func main() {
    // Only produce events where the namespace attribute is 0, and wiki is enwiki
    client := streams.NewClient().Match("namespace", 0).Match("wiki", "enwiki")

    // ...
}
Known issues
  • Only the recentchange stream is currently supported
  • Test coverage is very poor
  • Test connects to production Event Streams service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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