realtime

package
v0.0.0-...-1cdef85 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

Wikimedia Enterprise Realtime API SDK

Allows to quickly connect and start using WME Realtime API.

Getting started

Connect to the stream:

rlt := realtime.NewClient()
rlt.SetAccessToken(os.Getenv("WME_ACCESS_TOKEN"))

err := rlt.Articles(context.Background(), nil, func(art *schema.Article) error {
  log.Printf("name: %s\n", art.Name)
  return nil
})

if err != nil {
  log.Panic(err)
}

Documentation

Overview

Package realtime is a SDK for working with realtime API v2 BETA.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArticlesRequest

type ArticlesRequest struct {
	Since             time.Time         `json:"since,omitempty"`
	Fields            []string          `json:"fields,omitempty"`
	Filters           []Filter          `json:"filters,omitempty"`
	Parts             []int             `json:"parts,omitempty"`
	Offsets           map[int]int64     `json:"offsets,omitempty"`
	SincePerPartition map[int]time.Time ` json:"since_per_partition,omitempty"`
}

ArticlesRequest request for filtering and fields in realtime API.

type Client

type Client struct {
	BaseURL    string
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

Client realtime streaming client to simplify work with WME realtime API.

func NewClient

func NewClient() *Client

NewClient create new realtime client.

func (*Client) Articles

func (cl *Client) Articles(ctx context.Context, req *ArticlesRequest, cb func(art *schema.Article) error) error

Articles opens and listens articles stream.

func (*Client) GetAccessToken

func (c *Client) GetAccessToken() string

GetAccessToken returns value of the access token.

func (*Client) SetAccessToken

func (c *Client) SetAccessToken(accessToken string)

SetAccessToken sets access token for authentication.

type Filter

type Filter struct {
	Field string      `json:"field"`
	Value interface{} `json:"value"`
}

Filter payload for filters in realtime API.

Jump to

Keyboard shortcuts

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