email

package
v0.0.0-...-428fcb3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MPL-2.0 Imports: 18 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 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 PardotClient, perDayLimit float64, maxConcurrentRequests int, scope 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 PardotClient

type PardotClient interface {
	SendContact(email string) error
}

PardotClient is an interface for interacting with Pardot. It exists to facilitate testing mocks.

type PardotClientImpl

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

PardotClientImpl handles authentication and sending contacts to Pardot. It implements the PardotClient interface.

func NewPardotClientImpl

func NewPardotClientImpl(clk clock.Clock, businessUnit, clientId, clientSecret, oauthbaseURL, pardotBaseURL string) (*PardotClientImpl, error)

NewPardotClientImpl creates a new PardotClientImpl.

func (*PardotClientImpl) SendContact

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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