Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
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.