Documentation ¶
Index ¶
- Constants
- func CachingClientCreator(sc func(context.Context) (Odoo16Client, error)) func(context.Context) (Odoo16Client, error)
- type Config
- type FailedRecordScrubber
- type Odoo16Client
- type Odoo16Storage
- func (s *Odoo16Storage) Create(ctx context.Context, be *billingv1.BillingEntity) error
- func (s *Odoo16Storage) Get(ctx context.Context, name string) (*billingv1.BillingEntity, error)
- func (s *Odoo16Storage) List(ctx context.Context) ([]billingv1.BillingEntity, error)
- func (s *Odoo16Storage) Update(ctx context.Context, be *billingv1.BillingEntity) error
- type OdooClientWithFullInitialization
- type OdooCredentials
Constants ¶
const VSHNAccountingContactNameKey = "billing.appuio.io/vshn-accounting-contact-name"
Variables ¶
This section is empty.
Functions ¶
func CachingClientCreator ¶ added in v0.33.3
func CachingClientCreator(sc func(context.Context) (Odoo16Client, error)) func(context.Context) (Odoo16Client, error)
CachingClientCreator accepts and returns a function that creates a new Odoo16Client instance. The function caches the client instance returned from the upstream client creation function and returns it on subsequent calls. If an error occurs during the creation of the client, the error is returned and the client creation is retried on the next call. No client is cached if an error occurs during the creation.
This function is useful to avoid creating a new client instance for every request. Odoo clients track connections and session state internally, so reusing a client instance is beneficial. The upstream Odoo client is not thread-safe until a full initialization is performed. See the FullInitialization method on OdooClientWithFullInitialization for a workaround.
Types ¶
type FailedRecordScrubber ¶
type FailedRecordScrubber struct {
// contains filtered or unexported fields
}
func NewFailedRecordScrubber ¶
func NewFailedRecordScrubber(credentials OdooCredentials) *FailedRecordScrubber
func (*FailedRecordScrubber) CleanupIncompleteRecords ¶
func (s *FailedRecordScrubber) CleanupIncompleteRecords(ctx context.Context, minAge time.Duration) error
CleanupIncompleteRecords looks for partner records in Odoo that still have the "inflight" flag set despite being older than `minAge`. Those records are then deleted. Such records might come into existence due to a partially failed creation request.
type Odoo16Client ¶
type Odoo16Client interface { // FullInitialization performs a full initialization of the client. // After this call the client must be thread-safe and ready to use. FullInitialization() error Update(string, []int64, interface{}) error FindResPartners(*odooclient.Criteria, *odooclient.Options) (*odooclient.ResPartners, error) CreateResPartner(*odooclient.ResPartner) (int64, error) UpdateResPartner(*odooclient.ResPartner) error DeleteResPartners([]int64) error }
type Odoo16Storage ¶
type Odoo16Storage struct {
// contains filtered or unexported fields
}
func NewOdoo16Storage ¶
func NewOdoo16Storage(credentials OdooCredentials, conf Config) *Odoo16Storage
NewOdoo16Storage returns a new storage provider for BillingEntities The storage provider uses Odoo 16 as the backend.
func (*Odoo16Storage) Create ¶
func (s *Odoo16Storage) Create(ctx context.Context, be *billingv1.BillingEntity) error
func (*Odoo16Storage) Get ¶
func (s *Odoo16Storage) Get(ctx context.Context, name string) (*billingv1.BillingEntity, error)
func (*Odoo16Storage) List ¶
func (s *Odoo16Storage) List(ctx context.Context) ([]billingv1.BillingEntity, error)
func (*Odoo16Storage) Update ¶
func (s *Odoo16Storage) Update(ctx context.Context, be *billingv1.BillingEntity) error
type OdooClientWithFullInitialization ¶ added in v0.33.3
type OdooClientWithFullInitialization struct {
*odooclient.Client
}
OdooClientWithFullInitialization is a wrapper around the Odoo client that provides a FullInitialization method.
func (*OdooClientWithFullInitialization) FullInitialization ¶ added in v0.33.3
func (c *OdooClientWithFullInitialization) FullInitialization() error
FullInitialization is a workaround for the odooclient initialization which is not thread-safe. This function performs a full initialization of the client by calling execute_kw which initializes the "object" client. https://github.com/appuio/go-odoo/blob/a2a337fdf12becaeaa920ee8093402d6d01144f3/odoo.go#L337 After this call the client should be thread-safe and ready to use. The "common" client is already initialized in the NewClient function through the call of "authenticate". https://github.com/appuio/go-odoo/blob/a2a337fdf12becaeaa920ee8093402d6d01144f3/odoo.go#L53 https://github.com/appuio/go-odoo/blob/a2a337fdf12becaeaa920ee8093402d6d01144f3/odoo.go#L346
type OdooCredentials ¶
type OdooCredentials = odooclient.ClientConfig