endpoints

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package endpoints contains all request handler functions for Splice. Individual handlers are separated into their own files for readability.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessRequest

func ProcessRequest(ctx context.Context, w http.ResponseWriter, r *http.Request, checks []basic.Validator) models.Response

ProcessRequest takes a models.Request that is provided by the client, and validates it. A response is provided using models.Response.

func ProcessResult

func ProcessResult(w http.ResponseWriter, r *http.Request) *models.Response

ProcessResult requires a models.Status with a ClientID and a RequestID. It retrieves the current status of the request and provides a response to the client. If the request is ready to be returned, it finalizes the request and returns the join data as part of the response. If a request has become orphaned, it will release the request so that another splice joiner can claim it. Errors are returned in the context of models.Response.

Types

type AttendedRequestHandler

type AttendedRequestHandler struct{}

AttendedRequestHandler implements http.Handler for user interactive joins.

func (AttendedRequestHandler) ServeHTTP

type Client

type Client struct {
	Keys []*datastore.Key
	Req  *models.Request
	// contains filtered or unexported fields
}

Client is a datastore client that includes transaction relevant metadata.

func NewClient

func NewClient(ctx context.Context, req *models.Request) (*Client, server.StatusCode, error)

NewClient returns a splice datastore client to the caller.

func (*Client) Close

func (c *Client) Close() error

Close closes the datastore client.

func (*Client) CommitTx

func (c *Client) CommitTx() error

CommitTx finalizes and commits an existing transaction to the datastore. It must be called after StartTx. Other datastore actions such as Save and Find must take place prior to calling CommitTx.

func (*Client) Find

func (c *Client) Find(ctx context.Context, reqID string) (server.StatusCode, error)

Find searches for a previously committed request using the Request ID. Not Found is returned as a status code with a nil error.

func (*Client) FindOrphans

func (c *Client) FindOrphans(ctx context.Context, olderThan time.Duration, kind string) ([]*datastore.Key, []models.Request, error)

FindOrphans searches for requests that need to be cleaned up or were never processed.

func (*Client) RollbackTx

func (c *Client) RollbackTx() error

RollbackTx rolls back an in-flight transaction. It is typically used to ensure transaction cleanups when a processing error has occurred during processing.

func (*Client) Save

func (c *Client) Save(ctx context.Context) (server.StatusCode, error)

Save commits a request to the datastore. An int identifying the status is always returned to be passed to the Splice client.

func (*Client) StartTx

func (c *Client) StartTx(ctx context.Context) error

StartTx starts a new transaction in an existing datastore client. Other functions in this package require that a transaction exist prior to being used. Transactions started should be closed by the caller explicitly through CommitTx or at least through a defer statement.

type ResultHandler

type ResultHandler func(http.ResponseWriter, *http.Request) *models.Response

ResultHandler is a custom http handler that services domain join result status queries coming in from splice clients.

func (ResultHandler) ServeHTTP

func (rh ResultHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler and handles errors returned from ResultHandler.

type UnattendedRequestHandler

type UnattendedRequestHandler struct{}

UnattendedRequestHandler implements http.Handler for unattended joins.

func (UnattendedRequestHandler) ServeHTTP

Jump to

Keyboard shortcuts

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