salesforce

package
v0.20260526.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrQueueFull = errors.New("email-exporter queue is full")

Functions

This section is empty.

Types

type EmailCache

type EmailCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewHashedEmailCache

func NewHashedEmailCache(maxEntries int, stats prometheus.Registerer) *EmailCache

func (*EmailCache) Remove

func (c *EmailCache) Remove(email string)

func (*EmailCache) Seen

func (c *EmailCache) Seen(email string) bool

func (*EmailCache) StoreIfAbsent

func (c *EmailCache) StoreIfAbsent(email string) bool

StoreIfAbsent stores the email in the cache if it is not already present, as a single atomic operation. It returns true if the email was stored and false if it was already in the cache. If the cache is nil, true is always returned.

type ExporterImpl

type ExporterImpl struct {
	emailpb.UnsafeExporterServer

	sync.Mutex
	// contains filtered or unexported fields
}

ExporterImpl implements the gRPC server and processes email exports.

func NewExporterImpl

func NewExporterImpl(client SalesforceClient, cache *EmailCache, perDayLimit float64, maxConcurrentRequests int, stats prometheus.Registerer, logger blog.Logger) *ExporterImpl

NewExporterImpl initializes an ExporterImpl with the given client and configuration. Both perDayLimit and maxConcurrentRequests should be distributed proportionally among instances based on their share of the daily request cap. For example, if the total daily limit is 50,000 and one instance is assigned 40% (20,000 requests), it should also receive 40% of the max concurrent requests (e.g., 2 out of 5). For more details, see: https://developer.salesforce.com/docs/marketing/pardot/guide/overview.html?q=rate%20limits

func (*ExporterImpl) Drain

func (impl *ExporterImpl) Drain()

Drain blocks until all workers have finished processing the email queue.

func (*ExporterImpl) SendContacts

func (impl *ExporterImpl) SendContacts(ctx context.Context, req *emailpb.SendContactsRequest) (*emptypb.Empty, error)

SendContacts enqueues the provided email addresses. If the queue cannot accommodate the new emails, an ErrQueueFull is returned.

func (*ExporterImpl) Start

func (impl *ExporterImpl) Start(daemonCtx context.Context)

Start begins asynchronous processing of the email queue. When the parent daemonCtx is cancelled the queue will be drained and the workers will exit.

type SalesforceClient

type SalesforceClient interface {
	SendContact(email string) error
}

SalesforceClient is an interface for interacting with a limited set of Salesforce APIs. It exists to facilitate testing mocks.

type SalesforceClientImpl

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

SalesforceClientImpl handles authentication and sending contacts to Pardot.

func NewSalesforceClientImpl

func NewSalesforceClientImpl(clk clock.Clock, businessUnit, clientId, clientSecret, salesforceBaseURL, pardotBaseURL string) (*SalesforceClientImpl, error)

NewSalesforceClientImpl creates a new SalesforceClientImpl.

func (*SalesforceClientImpl) SendContact

func (pc *SalesforceClientImpl) SendContact(email string) error

SendContact submits an email to the Pardot Contacts endpoint, retrying up to 3 times with exponential backoff.

Directories

Path Synopsis
email

Jump to

Keyboard shortcuts

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