pushnotify

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package pushnotify resolves stored enrollment push information and topic certificates for notification delivery.

Design

Notifier looks up channel-specific targets, calls push.Pusher and publishes classified outcomes. StoreCertStore caches topic credentials and checks version changes on expiry of its TTL. Failed reloads return errors. Expiry queries support operator-managed renewal schedules.

PushTokenInvalid and PushRejected remain distinct because an inactive token and a topic/certificate configuration error require different handling. The transport-independent vocabulary stays in appleplatformservices/push; APNs acceptance does not establish device delivery.

References

Index

Constants

View Source
const DefaultCertTTL = 30 * time.Second

DefaultCertTTL is how long a StoreCertStore trusts a cached certificate before asking the store whether its Version moved.

Variables

This section is empty.

Functions

func ExpiringCerts

func ExpiringCerts(ctx context.Context, s storage.PushCertStore, now time.Time, within time.Duration) ([]storage.PushCert, error)

ExpiringCerts lists the stored certificates whose NotAfter is within `within` of now, or already past, so a deployment can schedule its own renewal check without a timer inside the library. The records carry no key material. An empty store yields an empty, non-nil slice.

Types

type CertStoreOption

type CertStoreOption func(*StoreCertStore)

CertStoreOption configures a StoreCertStore.

func WithCertClock

func WithCertClock(cl clock.Clock) CertStoreOption

WithCertClock sets the clock used for the TTL (tests).

func WithCertTTL

func WithCertTTL(d time.Duration) CertStoreOption

WithCertTTL sets how long a cached certificate is served before its Version is checked again (default DefaultCertTTL). A non-positive TTL revalidates on every call, which reproduces a per-push staleness check.

type Notifier

type Notifier struct {
	Store  storage.PushStore
	Pusher push.Pusher
	Bus    event.Publisher
	Clock  clock.Clock
}

Notifier pushes enrollments by id: it looks push info up in storage, sends through the Pusher, and publishes PushTokenInvalid for tokens APNs rejected.

func (*Notifier) Notify

func (n *Notifier) Notify(ctx context.Context, ids []mdm.EnrollmentID) (map[mdm.EnrollmentID]push.Result, error)

Notify pushes the given enrollments. Enrollments without push info (disabled or unknown) are skipped and reported with Err set.

type StoreCertStore

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

StoreCertStore serves push certificates from a storage.PushCertStore with a per-topic cache revalidated against the stored Version once per TTL (decision record 0015). A renewal written through StorePushCert bumps the Version, so it is picked up within one TTL without a query per push, and a failed reload returns an error rather than silently keeping the old certificate.

func NewStoreCertStore

func NewStoreCertStore(s storage.PushCertStore, opts ...CertStoreOption) *StoreCertStore

NewStoreCertStore returns a push.CertStore backed by s.

func (*StoreCertStore) PushCertificate

func (c *StoreCertStore) PushCertificate(ctx context.Context, topic string) (tls.Certificate, error)

PushCertificate implements push.CertStore. A cached certificate is returned as is inside the TTL. After the TTL the stored Version is read: when it is unchanged the cache entry is kept for another TTL, otherwise the PEM pair is loaded and parsed again. A topic the store does not know maps to push.ErrNoCertificate. The mutex is held only around cache reads and writes, never across a storage call.

Jump to

Keyboard shortcuts

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