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 PrettyPrintProto(m proto.Message) string
- 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 CustomProtoMessage
- type LongrunningOperation
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 PrettyPrintProto ¶
func ProcessLongRunningOperationToCompletion ¶
func ProcessLongRunningOperationToCompletion[ Req protoreflect.ProtoMessage, Resp protoreflect.ProtoMessage, ]( ctx context.Context, l *LongrunningOperation[Req, Resp], ) error
Types ¶
type CustomProtoMessage ¶
type CustomProtoMessage[M protoreflect.ProtoMessage] struct { Msg M }
CustomProtoMessage wraps a regular proto message with custom marshaling and unmarshaling to make it json encoding and decoding safe.
The regular JSON marshaller cannot operate correctly on proto messages as mentioned also in protojson golang specs.
func CreateCustomProtoMessage ¶
func CreateCustomProtoMessage[M protoreflect.ProtoMessage]( m M, ) *CustomProtoMessage[M]
func CreateCustomProtoMessageIterableFrom ¶
func CreateCustomProtoMessageIterableFrom[M protoreflect.ProtoMessage]( source []M, ) []*CustomProtoMessage[M]
func (*CustomProtoMessage[M]) MarshalJSON ¶
func (pm *CustomProtoMessage[M]) MarshalJSON() ([]byte, error)
func (*CustomProtoMessage[M]) UnmarshalJSON ¶
func (pm *CustomProtoMessage[M]) UnmarshalJSON(data []byte) error
type LongrunningOperation ¶
type LongrunningOperation[Req, Resp protoreflect.ProtoMessage] struct { OperationName string OperationError error OperationDone bool Request *CustomProtoMessage[Req] Response *CustomProtoMessage[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