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