core

package
v0.9.3-test1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DNSResolveFailedError = "Failed to find ip address"
View Source
const EncodeKeyEnvStr = "ENCODE_KEY"
View Source
const InvalidConnectionError = "Your connection configuration is invalid."
View Source
const InvalidEndpointError = "Failed to parse endpoint"
View Source
const InvalidParams = "Failed to decode request params"
View Source
const InvalidSchema = "Failed to find port for schema"
View Source
const NetworkConnectError = "Failed to connect to endpoint"
View Source
const SchemaIsRequired = "Endpoint schema is required"
View Source
const SourceIdError = "Missing or Invalid sourceId"
View Source
const UnmarshallingError = "There was a problem unmarshalling the response"
View Source
const UnsetConnectionError = "Your connection configuration is not set."

Variables

View Source
var DateTimeFormats []DateTimeFormatItem

Functions

func AddMissingSlashToURL added in v0.6.0

func AddMissingSlashToURL(baseUrl *string)

func AesDecrypt added in v0.8.0

func AesDecrypt(crypted, key []byte) ([]byte, error)

AES decryption

func AesEncrypt added in v0.8.0

func AesEncrypt(origData, key []byte) ([]byte, error)

AES encryption, CBC

func AllPlugins

func AllPlugins() map[string]Plugin

func ConvertStringToTime added in v0.4.0

func ConvertStringToTime(timeString string) (t time.Time, err error)

func Decode added in v0.8.0

func Decode(Input string) (string, error)

Base64 + AES decryption using ENCODE_KEY in .env as key

func DecodeMapStruct added in v0.6.0

func DecodeMapStruct(input map[string]interface{}, result interface{}) error

mapstructure.Decode with time.Time and Iso8601Time support

func Encode added in v0.8.0

func Encode(Input string) (string, error)

AES + Base64 encryption using ENCODE_KEY in .env as key

func FindPluginNameBySubPkgPath

func FindPluginNameBySubPkgPath(subPkgPath string) (string, error)

func GetRateLimitPerSecond added in v0.7.0

func GetRateLimitPerSecond(options map[string]interface{}, defaultValue int) (int, error)

func GetURIStringPointer added in v0.6.0

func GetURIStringPointer(baseUrl string, relativePath string, queryParams *url.Values) (*string, error)

func Iso8601TimeToTime added in v0.6.0

func Iso8601TimeToTime(iso8601Time *Iso8601Time) *time.Time

func PKCS7Padding added in v0.8.0

func PKCS7Padding(ciphertext []byte, blockSize int) []byte

PKCS7 padding

func PKCS7UnPadding added in v0.8.0

func PKCS7UnPadding(origData []byte) []byte

PKCS7 unPadding

func RandomCapsStr added in v0.8.0

func RandomCapsStr(len int) string

A random string of length len uppercase characters

func RegisterPlugin

func RegisterPlugin(name string, plugin Plugin) error

func RemoveStartingSlashFromPath added in v0.6.0

func RemoveStartingSlashFromPath(relativePath string) string

func UnmarshalResponse

func UnmarshalResponse(res *http.Response, v interface{}) error

Types

type ApiClient

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

func NewApiClient

func NewApiClient(
	endpoint string,
	headers map[string]string,
	timeout time.Duration,
	maxRetry int,
	scheduler *utils.WorkerScheduler,
) *ApiClient

func (*ApiClient) Do

func (apiClient *ApiClient) Do(
	method string,
	path string,
	query *url.Values,
	body *map[string]interface{},
	headers *map[string]string,
) (*http.Response, error)

func (*ApiClient) Get

func (apiClient *ApiClient) Get(
	path string,
	query *url.Values,
	headers *map[string]string,
) (*http.Response, error)

func (*ApiClient) GetAsync added in v0.9.0

func (apiClient *ApiClient) GetAsync(path string, queryParams *url.Values, handler func(*http.Response) error) error

func (*ApiClient) GetEndpoint added in v0.6.0

func (apiClient *ApiClient) GetEndpoint() string

func (*ApiClient) GetHeaders added in v0.6.0

func (apiClient *ApiClient) GetHeaders() map[string]string

func (*ApiClient) SetAfterFunction added in v0.6.0

func (apiClient *ApiClient) SetAfterFunction(callback ApiClientAfterResponse)

func (*ApiClient) SetBeforeFunction added in v0.4.0

func (apiClient *ApiClient) SetBeforeFunction(callback ApiClientBeforeRequest)

func (*ApiClient) SetContext added in v0.6.0

func (apiClient *ApiClient) SetContext(ctx context.Context)

func (*ApiClient) SetEndpoint

func (apiClient *ApiClient) SetEndpoint(endpoint string)

func (*ApiClient) SetHeaders

func (apiClient *ApiClient) SetHeaders(headers map[string]string)

func (*ApiClient) SetMaxRetry

func (ApiClient *ApiClient) SetMaxRetry(maxRetry int)

func (*ApiClient) SetProxy

func (apiClient *ApiClient) SetProxy(proxyUrl string) error

func (*ApiClient) SetTimeout

func (ApiClient *ApiClient) SetTimeout(timeout time.Duration)

func (*ApiClient) Setup

func (apiClient *ApiClient) Setup(
	endpoint string,
	headers map[string]string,
	timeout time.Duration,
	maxRetry int,
	scheduler *utils.WorkerScheduler,

)

func (*ApiClient) WaitOtherGoroutines added in v0.9.0

func (apiClient *ApiClient) WaitOtherGoroutines()

type ApiClientAfterResponse

type ApiClientAfterResponse func(res *http.Response) error

type ApiClientBeforeRequest

type ApiClientBeforeRequest func(req *http.Request) error

type ApiResourceHandler added in v0.3.0

type ApiResourceHandler func(input *ApiResourceInput) (*ApiResourceOutput, error)

type ApiResourceInput added in v0.3.0

type ApiResourceInput struct {
	Params map[string]string      // path variables
	Query  url.Values             // query string
	Body   map[string]interface{} // json body
}

type ApiResourceOutput added in v0.3.0

type ApiResourceOutput struct {
	Body   interface{} // response body
	Status int
}

type DateTimeFormatItem added in v0.4.0

type DateTimeFormatItem struct {
	Matcher *regexp.Regexp
	Format  string
}

type Iso8601Time

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

type Iso8601Time time.Time

func (Iso8601Time) MarshalJSON

func (jt Iso8601Time) MarshalJSON() ([]byte, error)

func (*Iso8601Time) String

func (jt *Iso8601Time) String() string

func (*Iso8601Time) ToNullableTime added in v0.9.0

func (jt *Iso8601Time) ToNullableTime() *time.Time

func (*Iso8601Time) ToTime

func (jt *Iso8601Time) ToTime() time.Time

func (*Iso8601Time) UnmarshalJSON

func (jt *Iso8601Time) UnmarshalJSON(b []byte) error

type Plugin

type Plugin interface {
	Description() string
	Init()
	Execute(options map[string]interface{}, progress chan<- float32, ctx context.Context) error
	// PkgPath information lost when compiled as plugin(.so)
	RootPkgPath() string
	ApiResources() map[string]map[string]ApiResourceHandler
}

func GetPlugin

func GetPlugin(name string) (Plugin, error)

type TestResult added in v0.6.0

type TestResult struct {
	Success bool
	Message string
}

func ValidateParams added in v0.6.0

func ValidateParams(input *ApiResourceInput, requiredParams []string) *TestResult

func (*TestResult) Set added in v0.6.0

func (testResult *TestResult) Set(success bool, message string)

Jump to

Keyboard shortcuts

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