Documentation
¶
Index ¶
- Variables
- func ComputeSubsequentRecordURLs(instanceURL string, firstNextRecordsURL string, secondNextRecordsURL string, ...) (URLs []string, err error)
- func ExtractUsageHeader(response *http.Response) (used int64, total int64, err error)
- func MergeJSONArrays(arrays ...[]byte) []byte
- func MustURL(str string, values *url.Values) *url.URL
- func ReadAndCloseResponse(r *http.Response) ([]byte, error)
- func Unmarshal(r *http.Response, dst interface{}) ([]byte, error)
- type Builder
- func (b Builder) Body(body io.Reader) Builder
- func (b Builder) Context(ctx context.Context) Builder
- func (b Builder) Header(key string, values ...string) Builder
- func (b Builder) Headers(header http.Header) Builder
- func (b Builder) JSON(dst interface{}) (body []byte, err error)
- func (b Builder) Marshal(item interface{}) Builder
- func (b Builder) Method(method string) Builder
- func (b Builder) Param(key, value string) Builder
- func (b Builder) QueryMore(selectBuilder soql.Builder, dst interface{}, includeSoftDelete bool) error
- func (b Builder) Request() (*http.Request, error)
- func (b Builder) Response() (*http.Response, error)
- func (b Builder) SQLizer(sqlizer sqlizer) Builder
- func (b Builder) Sender(sender sender) Builder
- func (b Builder) URL(str string) Builder
- func (b Builder) Values(values url.Values) Builder
- type RequestError
Constants ¶
This section is empty.
Variables ¶
var Base = Builder(builder.EmptyBuilder).Sender(DefaultSender)
Base ...
var DefaultSender = &defaultSender{}
var ErrUnmarshalEmpty = errors.New("could not unmarshal an empty buffer")
ErrUnmarshalEmpty ...
var JSON = Base.Header("Content-Type", "application/json")
JSON ...
Functions ¶
func ComputeSubsequentRecordURLs ¶
func ComputeSubsequentRecordURLs(instanceURL string, firstNextRecordsURL string, secondNextRecordsURL string, totalRecords int) (URLs []string, err error)
ComputeSubsequentRecordURLs identifies the cursor used for a query with multiple results pages and computes all subsequent page urls from the first two requests
i.e. query /query?q=select Name from Lead => returns firstNextRecordsURL: "some-url-1000" query firstNextRecordsURL => returns secondNextRecordsURL "some-url-2000" <-- calculate the increment computeSubsequentRecordURLs(firstNextRecordsURL, secondNextRecordsURL)
this allows us to then query asynchronously the remaining records asynchronously rather then walking them one at a time
NOTE: this behavior is dependant on salesforce pagination being predetermined after the first two requests. as far as I know, this implementation is undocumented and could change at any time. though it is VERY convenient and offers a massive performance improvement.
func ExtractUsageHeader ¶
ExtractUsageHeader extracts two integer value from the Sforce-Limit-Info header which contains a formatted string containing that information
Because we are extracting integer data from a complex string, this process is prone to error if an unexpected value is found
func MergeJSONArrays ¶
MergeJSONArrays takes many potentially large JSON arrays and merges them into a single array that can be unmarshalled into a single slice. Because of the performance impact of iterating through the entirety of an array we attempt to operate only on the first and last characters of the array.
This method is used to create better API signatures when bulk querying - where methods further down the call stack are re-used and don't know the specific type of the response but need to combine them anyways.
The same result can probably be achieved with less effort via the reflect package but this solution is succinct and works well enough.
There is also room to optimize memory usage by pre-computing the length of the final output.
func ReadAndCloseResponse ¶
ReadAndCloseResponse is a safety function that ensures we do not leak system resources by closing the http.Response Body after it is read
The semantics of body.Close() are a little confusing in Golang and because of the quantity of http requests we make in our applications it is easy to run out of system resources such as file descriptors
Types ¶
type Builder ¶
Builder ...
func (Builder) QueryMore ¶
func (b Builder) QueryMore(selectBuilder soql.Builder, dst interface{}, includeSoftDelete bool) error
QueryMore ...
type RequestError ¶
RequestError contains additional metadata about the http error
func (*RequestError) Error ¶
func (e *RequestError) Error() string
func (*RequestError) Unmarshal ¶
func (e *RequestError) Unmarshal(dst interface{}) error
Unmarshal ...
func (*RequestError) Unwrap ¶
func (e *RequestError) Unwrap() error