Documentation ¶
Index ¶
- Constants
- Variables
- func CompensatorAsError(compensator Compensator, err error) error
- func ErrorWithCode(code int, err error) error
- func ParseError(err, unknown error) error
- func RegisterBbanValidator(countryCode string, validator BbanValidator)
- func RegisterCountry(c Country)
- func RegisterNetworkOperators(countryIsoAlphaTwoCode string, nn ...NetworkOperator)
- func RegisterPhoneNumberResolver(countryTelCode string, resolver PhoneNumberResolver)
- type Bag
- type BankAccount
- type BbanValidator
- type ClosedInterval
- type Coded
- type Collection
- type Compensator
- type CompensatorFunc
- type Country
- type CountryCode
- type CountryName
- type Email
- type InternationalBankAccountNumber
- type LeftOpenInterval
- type MessageEnvelope
- type Money
- type NationalIdentityNumber
- type NetworkOperator
- type OpenInterval
- type PhoneNumber
- type PhoneNumberMetadata
- type PhoneNumberResolver
- type PrimaryAccountNumber
- type RightOpenInterval
- type Timespan
- type TrieNode
Constants ¶
View Source
const ( ErrCodeCanceled = iota + 1 ErrCodeUnknown ErrCodeInvalidArgument ErrCodeDeadlineExceeded ErrCodeNotFound ErrCodeAlreadyExists ErrCodePermissionDenied ErrCodeResourceExhausted ErrCodeFailedPrecondition ErrCodeAborted ErrCodeOutOfRange ErrCodeUnimplemented ErrCodeInternal ErrCodeDataLoss ErrCodeUnauthenticated )
Variables ¶
View Source
var ( ErrIbanIncorrectLength = errors.New("iban length incorrect") ErrIbanUnknownCountry = errors.New("iban country unknown") ErrIbanCheckFailure = errors.New("iban check failure") ErrIbanInvalidBban = errors.New("iban invalid bban") ErrPanIncorrectLength = errors.New("pan length incorrect") )
View Source
var ( ErrPhoneNumberUnknownCountry = errors.New("phone number country unknown") ErrUnknownNetworkOperator = errors.New("network operator unknown") )
View Source
var ( ErrRetryable = errors.New("temporary issue") ErrUnknown = ErrorWithCode(ErrCodeUnknown, errors.New("unknown error")) ErrCanceled = errors.Join(ErrRetryable, ErrorWithCode(ErrCodeCanceled, errors.New("operation was canceled"))) // ErrDeadlineExceeded indicates timeout has been reached regardless of operation result. // // May result in these http status codes: // * 408 // * 504 ErrDeadlineExceeded = errors.Join(ErrRetryable, ErrorWithCode(ErrCodeDeadlineExceeded, errors.New("operation expired before completion"))) // ErrResourceExhausted indicates some resource has been exhausted, // perhaps a per-user quota (like rate limiting), or perhaps the entire file system is out of space. // Situations like out-of-memory and server overload, or when a message is larger than the configured maximum size. // // May result in these http status codes: // * 429 // * 507 ErrResourceExhausted = errors.Join(ErrRetryable, ErrorWithCode(ErrCodeResourceExhausted, errors.New("resource has been exhausted"))) ErrCustomerSide = errors.New("customer-side error") ErrInvalidArgument = errors.Join(ErrCustomerSide, ErrorWithCode(ErrCodeInvalidArgument, errors.New("invalid argument"))) ErrUnauthenticated = errors.Join(ErrCustomerSide, ErrorWithCode(ErrCodeUnauthenticated, errors.New("caller not identified (unauthenticated)"))) ErrPermissionDenied = errors.Join(ErrCustomerSide, ErrorWithCode(ErrCodePermissionDenied, errors.New("caller identified but permission denied"))) ErrNotFound = errors.Join(ErrCustomerSide, ErrorWithCode(ErrCodeNotFound, errors.New("requested entity was not found"))) ErrAlreadyExists = errors.Join(ErrCustomerSide, ErrorWithCode(ErrCodeAlreadyExists, errors.New("entity already exists"))) ErrFailedPrecondition = errors.Join(ErrCustomerSide, ErrorWithCode(ErrCodeFailedPrecondition, errors.New("failed precondition"))) ErrOutOfRange = errors.Join(ErrCustomerSide, ErrorWithCode(ErrCodeOutOfRange, errors.New("operation was attempted past the valid range"))) ErrAborted = errors.Join(ErrCustomerSide, ErrorWithCode(ErrCodeAborted, errors.New("operation was aborted"))) ErrDataLoss = errors.Join(ErrCustomerSide, ErrorWithCode(ErrCodeDataLoss, errors.New("unrecoverable data loss or corruption"))) ErrSupplierSide = errors.New("supplier-side error") ErrInternal = errors.Join(ErrRetryable, ErrSupplierSide, ErrorWithCode(ErrCodeInternal, errors.New("some invariants expected by underlying system has been broken"))) ErrUnimplemented = errors.Join(ErrSupplierSide, ErrorWithCode(ErrCodeUnimplemented, errors.New("operation is not implemented or not supported/enabled in this service"))) ErrorWithCode(ErrCodeUnavailable, errors.New("service is currently unavailable"))) )
View Source
var EmptyNationalIdentityNumber = NationalIdentityNumber{}
View Source
var EmptyPhoneNumber = PhoneNumber{}
Functions ¶
func CompensatorAsError ¶ added in v0.4.0
func CompensatorAsError(compensator Compensator, err error) error
func ErrorWithCode ¶ added in v0.7.1
func ParseError ¶ added in v0.7.0
func RegisterBbanValidator ¶
func RegisterBbanValidator(countryCode string, validator BbanValidator)
func RegisterCountry ¶
func RegisterCountry(c Country)
func RegisterNetworkOperators ¶
func RegisterNetworkOperators(countryIsoAlphaTwoCode string, nn ...NetworkOperator)
func RegisterPhoneNumberResolver ¶
func RegisterPhoneNumberResolver(countryTelCode string, resolver PhoneNumberResolver)
Types ¶
type Bag ¶
type Bag[Value any] interface { // Pull takes out an item in case of existence. It should return ErrReachedEnd when nothing remained to return. Pull(ctx context.Context) (*Value, error) }
Bag is a container which items are non-returnable once pulled. Implementation of Pull must be thread-safe.
type BankAccount ¶
type BankAccount struct {
// contains filtered or unexported fields
}
func NewBankAccount ¶
func NewBankAccount(name string) BankAccount
func (BankAccount) BankName ¶
func (ba BankAccount) BankName() string
type BbanValidator ¶
type ClosedInterval ¶
func (ClosedInterval[T]) Contains ¶
func (tt ClosedInterval[T]) Contains(e T) bool
type Collection ¶
Collection is the set of objects
type Compensator ¶ added in v0.4.0
type CompensatorFunc ¶ added in v0.4.0
func (CompensatorFunc) Compensate ¶ added in v0.4.0
func (cf CompensatorFunc) Compensate(ctx context.Context, err error) error
type Country ¶
type Country struct { EnglishName CountryName Codes CountryCode }
Country useful links: http://download.geonames.org/export/dump/countryInfo.txt, https://github.com/mledoze/countries/blob/master/countries.json
type CountryCode ¶
type CountryCode struct { // IsoAlphaTwo contains ISO 3166-1 alpha-2 code // useful links: https://en.wikipedia.org/wiki/ISO_3166-1 and https://www.iban.com/country-codes IsoAlphaTwo string // IsoAlphaThree contains ISO 3166-1 alpha-3 code // useful links: https://en.wikipedia.org/wiki/ISO_3166-1 and https://www.iban.com/country-codes IsoAlphaThree string // IsoNumeric contains ISO 3166-1 numeric code // useful links: https://en.wikipedia.org/wiki/ISO_3166-1 and https://www.iban.com/country-codes IsoNumeric string // IocAlphaThree contains international olympic committee alphabetic country code // useful links: https://en.wikipedia.org/wiki/List_of_IOC_country_codes IocAlphaThree string // Telephone is the calling code // useful links: https://en.wikipedia.org/wiki/List_of_country_calling_codes Telephone string }
CountryCode contains country unique codes in different standards
type CountryName ¶
type InternationalBankAccountNumber ¶
type InternationalBankAccountNumber struct { Country *Country // contains filtered or unexported fields }
func ParseInternationalBankAccountNumber ¶
func ParseInternationalBankAccountNumber(iban string) (*InternationalBankAccountNumber, error)
func (InternationalBankAccountNumber) String ¶
func (iban InternationalBankAccountNumber) String() string
type LeftOpenInterval ¶
func (LeftOpenInterval[T]) Contains ¶
func (tt LeftOpenInterval[T]) Contains(e T) bool
type MessageEnvelope ¶ added in v0.2.8
type NationalIdentityNumber ¶
type NationalIdentityNumber struct{}
func ParseNationalIdentityNumber ¶
func ParseNationalIdentityNumber(number string) (*NationalIdentityNumber, error)
type NetworkOperator ¶
func NetworkOperatorsByCountryCode ¶
func NetworkOperatorsByCountryCode(code string) []NetworkOperator
NetworkOperatorsByCountryCode Lists registered NetworkOperator(s) of a country where code is iso alpha-2 code
type OpenInterval ¶
func (OpenInterval[T]) Contains ¶
func (tt OpenInterval[T]) Contains(e T) bool
type PhoneNumber ¶
type PhoneNumber struct { Country *Country Mobile bool Prepaid bool DefaultOperator NetworkOperator // contains filtered or unexported fields }
func MustParsePhoneNumber ¶
func MustParsePhoneNumber(number string) PhoneNumber
func ParsePhoneNumber ¶
func ParsePhoneNumber(number string) (*PhoneNumber, error)
func (PhoneNumber) String ¶
func (pn PhoneNumber) String() string
type PhoneNumberMetadata ¶
type PhoneNumberMetadata struct { Mobile bool Prepaid bool Operator NetworkOperator }
type PhoneNumberResolver ¶
type PhoneNumberResolver func(localNumber string) (*PhoneNumberMetadata, error)
type PrimaryAccountNumber ¶
type PrimaryAccountNumber struct {
// contains filtered or unexported fields
}
func ParsePrimaryAccountNumber ¶
func ParsePrimaryAccountNumber(pan string) (*PrimaryAccountNumber, error)
func (PrimaryAccountNumber) String ¶
func (pan PrimaryAccountNumber) String() string
type RightOpenInterval ¶
func (RightOpenInterval[T]) Contains ¶
func (tt RightOpenInterval[T]) Contains(e T) bool
type TrieNode ¶
type TrieNode[Key, KeyAtom comparable, Value any] struct { // contains filtered or unexported fields }
func Trie ¶
func Trie[Key, KeyAtom comparable, Value any](atomizer func(Key) []KeyAtom) *TrieNode[Key, KeyAtom, Value]
Source Files ¶
Click to show internal directories.
Click to hide internal directories.