trs_http_api

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DFLT_RETRY_MAX   = 3 //default max # of retries on failure
	DFLT_BACKOFF_MAX = 5 //default max seconds per retry
)

Variables

This section is empty.

Functions

func ExecuteTask

func ExecuteTask(tloc *TRSHTTPLocal, tct taskChannelTuple)

func SendDelayedError

func SendDelayedError(tct taskChannelTuple, logger *logrus.Logger)

Types

type HttpKafkaRx

type HttpKafkaRx struct {
	ID       uuid.UUID // message ID
	Response *SerializedResponse
	Err      *error
}

type HttpKafkaTx

type HttpKafkaTx struct {
	ID          uuid.UUID
	Request     SerializedRequest `json:",omitempty"`
	TimeStamp   string            `json:",omitempty"` // Time the request time.Now().String()
	Timeout     time.Duration     `json:",omitempty"`
	RetryPolicy RetryPolicy
	ServiceName string
	Ignore      bool
}

func (HttpKafkaTx) ToHttpTask

func (tx HttpKafkaTx) ToHttpTask() (ht HttpTask)

type HttpTask

type HttpTask struct {
	ServiceName string //name of the service
	Request     *http.Request
	TimeStamp   string // Time the request was created/sent RFC3339Nano
	Err         *error
	Timeout     time.Duration
	RetryPolicy RetryPolicy
	Ignore      bool
	// contains filtered or unexported fields
}

func (*HttpTask) GetID

func (ht *HttpTask) GetID() (uuid uuid.UUID)

func (*HttpTask) SetIDIfNotPopulated

func (ht *HttpTask) SetIDIfNotPopulated() uuid.UUID

func (HttpTask) ToHttpKafkaRx

func (ht HttpTask) ToHttpKafkaRx() (rx HttpKafkaRx)

func (HttpTask) ToHttpKafkaTx

func (ht HttpTask) ToHttpKafkaTx() (tx HttpKafkaTx)

func (HttpTask) Validate

func (ht HttpTask) Validate() (valid bool, err error)

type RetryPolicy

type RetryPolicy struct {
	Retries        int
	BackoffTimeout time.Duration
}

type SerializedRequest

type SerializedRequest struct {
	Method           string               `json:",omitempty"`
	URL              *url.URL             `json:",omitempty"`
	Proto            string               `json:",omitempty"` // "HTTP/1.0"
	ProtoMajor       int                  `json:",omitempty"` // 1
	ProtoMinor       int                  `json:",omitempty"` // 0
	Header           http.Header          `json:",omitempty"`
	Body             []byte               `json:",omitempty"`
	ContentLength    int64                `json:",omitempty"`
	TransferEncoding []string             `json:",omitempty"`
	Close            bool                 `json:",omitempty"`
	Host             string               `json:",omitempty"`
	Form             url.Values           `json:",omitempty"`
	PostForm         url.Values           `json:",omitempty"` // Go 1.1
	MultipartForm    *multipart.Form      `json:",omitempty"`
	Trailer          http.Header          `json:",omitempty"`
	RemoteAddr       string               `json:",omitempty"`
	RequestURI       string               `json:",omitempty"`
	TLS              *tls.ConnectionState `json:",omitempty"`
}

func ToSerializedRequest

func ToSerializedRequest(req http.Request) (sr SerializedRequest)

func (SerializedRequest) Equal

func (sr SerializedRequest) Equal(sr1 SerializedRequest) (equal bool)

func (SerializedRequest) ToHttpRequest

func (sr SerializedRequest) ToHttpRequest() (req http.Request)

type SerializedResponse

type SerializedResponse struct {
	Status           string // e.g. "200 OK"
	StatusCode       int    // e.g. 200
	Proto            string // e.g. "HTTP/1.0"
	ProtoMajor       int    // e.g. 1
	ProtoMinor       int    // e.g. 0
	Header           http.Header
	Body             []byte
	ContentLength    int64
	TransferEncoding []string
	Close            bool
	Uncompressed     bool
	Trailer          http.Header
	TLS              *tls.ConnectionState
}

func ToSerializedResponse

func ToSerializedResponse(resp http.Response) (sr SerializedResponse)

func (SerializedResponse) Equal

func (sr SerializedResponse) Equal(sr1 SerializedResponse) (equal bool)

func (SerializedResponse) ToHttpResponse

func (sr SerializedResponse) ToHttpResponse() (resp http.Response)

type TRSHTTPLocal

type TRSHTTPLocal struct {
	Logger *logrus.Logger

	CACertPool *x509.CertPool
	ClientCert tls.Certificate
	// contains filtered or unexported fields
}

func (*TRSHTTPLocal) Alive

func (tloc *TRSHTTPLocal) Alive() (bool, error)

func (*TRSHTTPLocal) Cancel

func (tloc *TRSHTTPLocal) Cancel(taskList *[]HttpTask)

func (*TRSHTTPLocal) Check

func (tloc *TRSHTTPLocal) Check(taskList *[]HttpTask) (bool, error)

func (*TRSHTTPLocal) Cleanup

func (tloc *TRSHTTPLocal) Cleanup()

func (*TRSHTTPLocal) Close

func (tloc *TRSHTTPLocal) Close(taskList *[]HttpTask)

func (*TRSHTTPLocal) CreateTaskList

func (tloc *TRSHTTPLocal) CreateTaskList(source *HttpTask, numTasks int) []HttpTask

func (*TRSHTTPLocal) Init

func (tloc *TRSHTTPLocal) Init(serviceName string, logger *logrus.Logger) error

func (*TRSHTTPLocal) Launch

func (tloc *TRSHTTPLocal) Launch(taskList *[]HttpTask) (chan *HttpTask, error)

func (*TRSHTTPLocal) SetSecurity

func (tloc *TRSHTTPLocal) SetSecurity(inParams interface{}) error

type TRSHTTPLocalSecurity

type TRSHTTPLocalSecurity struct {
	CACertBundleData string
	ClientCertData   string
	ClientKeyData    string
}

type TRSHTTPRemote

type TRSHTTPRemote struct {
	Logger *logrus.Logger

	KafkaInstance *tkafka.TRSKafka
	// contains filtered or unexported fields
}

func (*TRSHTTPRemote) Alive

func (tloc *TRSHTTPRemote) Alive() (bool, error)

func (*TRSHTTPRemote) Cancel

func (tloc *TRSHTTPRemote) Cancel(taskList *[]HttpTask)

func (*TRSHTTPRemote) Check

func (tloc *TRSHTTPRemote) Check(taskList *[]HttpTask) (bool, error)

func (*TRSHTTPRemote) Cleanup

func (tloc *TRSHTTPRemote) Cleanup()

Clean up a Remote HTTP task system.

func (*TRSHTTPRemote) Close

func (tloc *TRSHTTPRemote) Close(taskList *[]HttpTask)

func (*TRSHTTPRemote) CreateTaskList

func (tloc *TRSHTTPRemote) CreateTaskList(source *HttpTask, numTasks int) []HttpTask

func (*TRSHTTPRemote) Init

func (tloc *TRSHTTPRemote) Init(serviceName string, logger *logrus.Logger) error

func (*TRSHTTPRemote) Launch

func (tloc *TRSHTTPRemote) Launch(taskList *[]HttpTask) (chan *HttpTask, error)

func (*TRSHTTPRemote) SetSecurity

func (tloc *TRSHTTPRemote) SetSecurity(inParams interface{}) error

type TrsAPI

type TrsAPI interface {
	Init(serviceName string, logger *logrus.Logger) error
	SetSecurity(params interface{}) error
	CreateTaskList(source *HttpTask, numTasks int) []HttpTask
	Launch(taskList *[]HttpTask) (chan *HttpTask, error)
	Check(taskList *[]HttpTask) (running bool, err error)
	Cancel(taskList *[]HttpTask)
	Close(taskList *[]HttpTask)
	Alive() (ok bool, err error)
	Cleanup()
}

Jump to

Keyboard shortcuts

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