Documentation
¶
Index ¶
- func CaseInsensitiveKeyMapJoin[value any](primary, addOn map[string]value) map[string]value
- func DoHTTPCommunication(ctx context.Context, url, httpMethod string, reqBody io.Reader, ...) (statusCode int, respBody []byte, err error)
- func DoHTTPStreamedCommunication(ctx context.Context, url, httpMethod string, reqBody io.Reader, ...) (statusCode int, respBody io.ReadCloser, err error)
- func DoProtoHTTPCommunication(ctx context.Context, url, httpMethod string, req protoreflect.ProtoMessage, ...) (statusCode int, err error)
- func DownloadAndUpload(ctx context.Context, downloadURL string, downloadHeaders map[string]string, ...) error
- func DownloadURLToPath(ctx context.Context, filePath string, downloadURL string) error
- func ExtractPayloadFromZip(zipfilePath string, filename string) ([]byte, error)
- func GetLongRunningOperationResult(ctx context.Context, name string, ...) error
- func ProcessLongRunningOperationToCompletion[Req protoreflect.ProtoMessage, Resp protoreflect.ProtoMessage](ctx context.Context, l *LongrunningOperation[Req, Resp]) error
- func RetryFunc(timeout time.Duration, fn func() error) error
- type LongrunningOperation
- func (l *LongrunningOperation[Req, Resp]) GetRequest() Req
- func (l *LongrunningOperation[Req, Resp]) GetResponse() Resp
- func (l *LongrunningOperation[Req, Resp]) MarshalJSON() ([]byte, error)
- func (l *LongrunningOperation[Req, Resp]) Process(ctx context.Context) (bool, error)
- func (l *LongrunningOperation[Req, Resp]) UnmarshalJSON(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoHTTPCommunication ¶
func DoHTTPCommunication( ctx context.Context, url, httpMethod string, reqBody io.Reader, reqHeaders map[string]string, ) (statusCode int, respBody []byte, err error)
DoHTTPCommunication is a thin-wrapper over basic HTTP communication.
Parameters: - url: url to send request to. - httpMethod: HTTP method used to send request. - reqBody: message body to send with HTTP request. (if nil, then no body is sent) - reqHeaders: Headers to set with HTTP request.
Returns: - statusCode: HTTP status code. - respBody: Response body. - err: error.
func DoHTTPStreamedCommunication ¶
func DoHTTPStreamedCommunication( ctx context.Context, url, httpMethod string, reqBody io.Reader, reqHeaders map[string]string, ) (statusCode int, respBody io.ReadCloser, err error)
DoHTTPStreamedCommunication is a thin-wrapper over basic HTTP communication where the response is not read by the function but rather the caller is responsible the body contents and closing the reader when done.
Parameters: - url: url to send request to. - httpMethod: HTTP method used to send request. - reqBody: message body to send with HTTP request. (if nil, then no body is sent) - reqHeaders: Headers to set with HTTP request.
Returns: - statusCode: HTTP status code. - respBody: Response body reader. (only set when there is no error) - err: error.
func DoProtoHTTPCommunication ¶
func DoProtoHTTPCommunication( ctx context.Context, url, httpMethod string, req protoreflect.ProtoMessage, reqHeaders map[string]string, resp protoreflect.ProtoMessage, ) (statusCode int, err error)
DoProtoHTTPCommunication does HTTP communication over proto defined messages.
Parameters: - url: URL to send request to. - httpMethod: HTTP method used to send request. - req: Proto message to be used as request body. (if nil, then no body is sent) - reqHeaders: Headers to set with HTTP request. - resp: on success, the response is decoded and set to this. (if nil, then no response body is expected)
Returns: - statusCode: HTTP status code. - err: error.
func DownloadAndUpload ¶
func DownloadAndUpload( ctx context.Context, downloadURL string, downloadHeaders map[string]string, uploadURL string, uploadHeaders map[string]string, ) error
Uses Get to download and PUT to upload
func DownloadURLToPath ¶
func ExtractPayloadFromZip ¶
func GetLongRunningOperationResult ¶
func GetLongRunningOperationResult( ctx context.Context, name string, f func(context.Context, *longrunningpb.GetOperationRequest) (*longrunningpb.Operation, error), dst protoreflect.ProtoMessage, ) error
func ProcessLongRunningOperationToCompletion ¶
func ProcessLongRunningOperationToCompletion[ Req protoreflect.ProtoMessage, Resp protoreflect.ProtoMessage, ]( ctx context.Context, l *LongrunningOperation[Req, Resp], ) error
Types ¶
type LongrunningOperation ¶
type LongrunningOperation[Req, Resp protoreflect.ProtoMessage] struct { OperationName string OperationError error OperationDone bool Request Req Response Resp // contains filtered or unexported fields }
func CreateLongrunningOperation ¶
func CreateLongrunningOperation[Req, Resp protoreflect.ProtoMessage]( trigger func(ctx context.Context, req Req) (*longrunningpb.Operation, error), get func(ctx context.Context, req *longrunningpb.GetOperationRequest) (*longrunningpb.Operation, error), req Req, ) *LongrunningOperation[Req, Resp]
func (*LongrunningOperation[Req, Resp]) GetRequest ¶
func (l *LongrunningOperation[Req, Resp]) GetRequest() Req
func (*LongrunningOperation[Req, Resp]) GetResponse ¶
func (l *LongrunningOperation[Req, Resp]) GetResponse() Resp
func (*LongrunningOperation[Req, Resp]) MarshalJSON ¶
func (l *LongrunningOperation[Req, Resp]) MarshalJSON() ([]byte, error)
func (*LongrunningOperation[Req, Resp]) Process ¶
func (l *LongrunningOperation[Req, Resp]) Process(ctx context.Context) (bool, error)
func (*LongrunningOperation[Req, Resp]) UnmarshalJSON ¶
func (l *LongrunningOperation[Req, Resp]) UnmarshalJSON(data []byte) error