fbbatch

package
v0.0.0-...-07c8964 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2015 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package fbbatch provides a Client with single call semantics which will automatically use Facebook Graph Batch implementation under the hood.

This allows for transparently using batching for greater efficiency. You should be aware of how the Facebook Graph API resource limits are applicable for your use case and configure the client appropriately.

For the official documentation look at: https://developers.facebook.com/docs/reference/api/batch/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	AccessToken string
	AppID       uint64
	Request     []*Request
}

Batch of Requests.

type Client

type Client struct {
	Client      *fbapi.Client
	AccessToken string
	AppID       uint64

	// Capacity of log channel. Defaults to 1000.
	PendingWorkCapacity uint

	// Maximum number of items in a batch. Defaults to 50.
	MaxBatchSize uint

	// Amount of time after which to send a pending batch. Defaults to 10ms.
	BatchTimeout time.Duration
	// contains filtered or unexported fields
}

Client with the same interface as fbapi.Client but one where the underlying requests are automatically batched together.

func (*Client) Do

func (c *Client) Do(req *http.Request, result interface{}) (*http.Response, error)

Do performs a Graph API request and unmarshal it's response. If the response is an error, it will be returned as an error, else it will be unmarshalled into the result.

func (*Client) Stop

func (c *Client) Stop() error

Stop and gracefully wait for the background worker to finish processing pending requests.

type Header struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Header in a Batch Response.

type Request

type Request struct {
	Name        string `json:"name,omitempty"`
	Method      string `json:"method,omitempty"`
	RelativeURL string `json:"relative_url"`
	Body        string `json:"body,omitempty"`
}

Request in a Batch.

type Response

type Response struct {
	Code   int      `json:"code"`
	Header []Header `json:"headers"`
	Body   string   `json:"body,omitempty"`
}

Response in a Batch.

func BatchDo

func BatchDo(c *fbapi.Client, b *Batch) ([]*Response, error)

BatchDo performs a Batch call. Errors are only returned if the batch itself fails, not for the individual requests.

Jump to

Keyboard shortcuts

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