sender

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPProto10 = "HTTP/1.0"
	HTTPProto11 = "HTTP/1.1"
	HTTPProto20 = "HTTP/2.0"
)

Variables

View Source
var (
	ErrProjectIDMustBeSet = errors.New("sender: project ID must be set")
	ErrRequestNotFound    = errors.New("sender: request not found")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Scope         *scope.Scope
	Repository    Repository
	ReqLogService reqlog.Service
	HTTPClient    *http.Client
}

type FindRequestsFilter

type FindRequestsFilter struct {
	ProjectID   ulid.ULID
	OnlyInScope bool
	SearchExpr  search.Expression
}

type HTTPTransport

type HTTPTransport struct{}

func (*HTTPTransport) RoundTrip

func (t *HTTPTransport) RoundTrip(req *http.Request) (*http.Response, error)

RountTrip implements http.RoundTripper. Based on a context value on the HTTP request, it switches between using `http.DefaultTransport` (which attempts HTTP/2) and a HTTP/1.1 only transport that's based off `http.DefaultTransport`.

type Repository

type Repository interface {
	FindSenderRequestByID(ctx context.Context, id ulid.ULID) (Request, error)
	FindSenderRequests(ctx context.Context, filter FindRequestsFilter, scope *scope.Scope) ([]Request, error)
	StoreSenderRequest(ctx context.Context, req Request) error
	StoreResponseLog(ctx context.Context, reqLogID ulid.ULID, resLog reqlog.ResponseLog) error
	DeleteSenderRequests(ctx context.Context, projectID ulid.ULID) error
}

type Request

type Request struct {
	ID                 ulid.ULID
	ProjectID          ulid.ULID
	SourceRequestLogID ulid.ULID

	URL    *url.URL
	Method string
	Proto  string
	Header http.Header
	Body   []byte

	Response *reqlog.ResponseLog
}

func (Request) MatchScope

func (req Request) MatchScope(s *scope.Scope) bool

func (Request) Matches

func (req Request) Matches(expr search.Expression) (bool, error)

Matches returns true if the supplied search expression evaluates to true.

type SendError

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

func (SendError) Error

func (e SendError) Error() string

func (SendError) Unwrap

func (e SendError) Unwrap() error

type Service

type Service interface {
	FindRequestByID(ctx context.Context, id ulid.ULID) (Request, error)
	FindRequests(ctx context.Context) ([]Request, error)
	CreateOrUpdateRequest(ctx context.Context, req Request) (Request, error)
	CloneFromRequestLog(ctx context.Context, reqLogID ulid.ULID) (Request, error)
	DeleteRequests(ctx context.Context, projectID ulid.ULID) error
	SendRequest(ctx context.Context, id ulid.ULID) (Request, error)
	SetActiveProjectID(ulid.ULID)
	SetFindReqsFilter(filter FindRequestsFilter)
	FindReqsFilter() FindRequestsFilter
}

func NewService

func NewService(cfg Config) Service

Jump to

Keyboard shortcuts

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