s3rpc

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: MIT Imports: 20 Imported by: 1

README

Tests on Linux, MacOS and Windows Go Report Card GoDoc

RPC via AWS S3 and SQS.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProvisioner

func NewProvisioner(name, region string) (awscreate.Provisioner[s3rpccreate.CreateResults], error)

NewProvisioner returns a new Provisioner that can be used to create and destroy an AWS environment with all the users, buckets and queues needed for s3rpc. Pass the result into PrintProvisionResults.

func PrintProvisionResults

func PrintProvisionResults(outputs s3rpccreate.CreateResults)

PrintProvisionResults prints the config releventa parts of the provision results to stdout, sutiable for sourcing in a shell script.

Types

type AWSConfig

type AWSConfig struct {
	Region          string
	Bucket          string
	AccessKeyID     string
	SecretAccessKey string
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client for executing operations on a server.

func NewClient

func NewClient(opts ClientOptions) (*Client, error)

NewClient creates a new client.

func (*Client) Close

func (c *Client) Close() error

Close removes the temporary directory.

func (*Client) Execute added in v0.2.0

func (c *Client) Execute(ctx context.Context, op string, input Input) (Output, error)

Execute executes the given op on a server with input.Filename as its main input. This will block until the response is received or the timeout is reached. Note that Output.Filename should be considered temporary and will be removed on Close.

func (Client) Receive

func (c Client) Receive(ctx context.Context) ([]message, error)

type ClientOptions

type ClientOptions struct {
	// The out queue to listen for responses from server.
	Queue string

	// Timeout is the maximum time to wait for a response from the server.
	Timeout time.Duration

	// Infof logs info messages.
	Infof func(format string, args ...interface{})

	// The AWS config.
	AWSConfig
}

type Handlers

type Handlers map[string]func(ctx context.Context, input Input) (Output, error)

Handlers is a map of operation names to handler functions.

type Input added in v0.2.0

type Input struct {
	Filename string
	Metadata map[string]string
}

Input is the input to a handler invocation.

type Output

type Output struct {
	Filename string
	Metadata map[string]string
}

Output is the result of a handler invocation.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a server that processes files from an S3 bucket.

func NewServer

func NewServer(opts ServerOptions) (*Server, error)

NewServer creates a new server.

func (*Server) Close

func (s *Server) Close() error

Close closes the server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context) error

ListenAndServe listens for messages and processes them. It blocks until the server is closed.

func (Server) Receive

func (c Server) Receive(ctx context.Context) ([]message, error)

type ServerOptions

type ServerOptions struct {
	// Handlers maps an operation to a handler.
	// The operation is also the first path segment below in/out in the bucket.
	Handlers Handlers

	// The in queue to poll for new messages.
	Queue string

	// PollInterval is the interval between polling for new messages.
	PollInterval time.Duration

	// Infof logs info messages.
	Infof func(format string, args ...interface{})

	// The AWS config.
	AWSConfig
}

ServerOptions are options for the server.

Jump to

Keyboard shortcuts

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