仕事で
スタンダードな
参考に した ライブラリ
sanitize処理などの
あとは、client_secret、refresh_token、access_tokenなど)をREDACTEDに
https://github.com/sho-hata/go-moneytree/blob/main/gomoneytree.go#L430
少しだけユニークな 実装ポイント
指数関数的バックオフアルゴリズムに よる 再試行
Moneytree LINK APIの
実装では、RetryConfig構造体で
待機時間 = ベースディレイ × 2^リトライ回数 ± ジッター
ジッターは
実装は
https://github.com/sho-hata/go-moneytree/blob/main/gomoneytree.go#L210
他の
Functional Pattern に よる オプショナルな クエリパラメータ設定
実験的に、
例えば、GetPersonalAccountsメソッドでは、WithPageやWithPerPageとGetPersonalAccountsOption型func(*getPersonalAccountsOptions))を
type GetPersonalAccountsOption func(*getPersonalAccountsOptions)
type getPersonalAccountsOptions struct {
paginationOptions
}
// WithPage specifies the page number for pagination.
// Page numbers start from 1. The default value is 1.
// Valid range is 1 to 100000.
func WithPage(page int) GetPersonalAccountsOption {
return func(opts *getPersonalAccountsOptions) {
opts.Page = &page
}
}
// WithPerPage specifies the number of items per page.
// The default value is 500. Valid range is 1 to 500.
func WithPerPage(perPage int) GetPersonalAccountsOption {
return func(opts *getPersonalAccountsOptions) {
opts.PerPage = &perPage
}
}実装:https://github.com/sho-hata/go-moneytree/blob/main/personalaccount.go#L64
呼び出し側の
accounts, err := client.GetPersonalAccounts(ctx,
moneytree.WithPage(1),
moneytree.WithPerPage(100),
)オプショナルな
一方で
「可読性
と
