constants

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package constants defines shared context key types used throughout the mailing list service.

Package constants defines global constants used throughout the mailing list service.

Package constants defines OpenFGA relation constants used throughout the mailing list service.

Package constants defines validation constants and formats for the mailing list service.

Index

Constants

View Source
const (
	// ProjectGetSlugSubject is the NATS subject for getting project slug
	ProjectGetSlugSubject = "lfx.projects-api.get_slug"
	// ProjectGetNameSubject is the NATS subject for getting project name
	ProjectGetNameSubject = "lfx.projects-api.get_name"
	// ProjectGetParentUIDSubject is the NATS subject for getting project parent UID
	ProjectGetParentUIDSubject = "lfx.projects-api.get_parent_uid"

	// CommitteeGetNameSubject is the NATS subject for getting committee name
	CommitteeGetNameSubject = "lfx.committee-api.get_name"
)

NATS messaging subjects

View Source
const (
	// EnvNATSURL is the environment variable for NATS server URL
	EnvNATSURL = "NATS_URL"
	// EnvNATSCredentials is the environment variable for NATS credentials
	EnvNATSCredentials = "NATS_CREDENTIALS"
)

Environment variables

View Source
const (
	// ResourceTypeService represents a GroupsIO service resource
	ResourceTypeService = "service"
	// ResourceTypeMember represents a GroupsIO member resource
	ResourceTypeMember = "member"
	// ResourceTypeMailingList represents a GroupsIO mailing list resource
	ResourceTypeMailingList = "mailing_list"
)

Resource type constants for domain resolution

View Source
const (
	// RelationProject defines the project relation used for inheritance
	RelationProject = "project"

	// RelationCommittee defines the committee relation used for committee-based authorization
	RelationCommittee = "committee"

	// RelationGroupsIOService defines the parent service relation used for service-level authorization inheritance
	RelationGroupsIOService = "groupsio_service"

	// RelationMailingList defines the parent mailing list relation used for member-level authorization inheritance
	RelationMailingList = "groupsio_mailing_list"

	// RelationViewer defines the viewer permission level
	RelationViewer = "viewer"

	// RelationWriter defines the writer permission level
	RelationWriter = "writer"

	// RelationOwner defines the owner permission level
	RelationOwner = "owner"

	// RelationMember defines the member permission level
	RelationMember = "member"

	// RelationAuditor defines the auditor permission level
	RelationAuditor = "auditor"
)

OpenFGA relation constants for authorization and access control

View Source
const (
	// ObjectTypeGroupsIOService defines the object type for GroupsIO services
	ObjectTypeGroupsIOService = "groupsio_service"

	// ObjectTypeGroupsIOMailingList defines the object type for GroupsIO mailing lists
	ObjectTypeGroupsIOMailingList = "groupsio_mailing_list"

	// ObjectTypeUser defines the object type for users
	ObjectTypeUser = "user"
)

OpenFGA object type constants

View Source
const (
	// ModStatusNone indicates a regular member with no special privileges
	ModStatusNone = "none"

	// ModStatusModerator indicates a member with moderation privileges (writer permissions)
	ModStatusModerator = "moderator"

	// ModStatusOwner indicates a member with owner privileges (owner permissions)
	ModStatusOwner = "owner"
)

Member moderation status constants

View Source
const (
	ServiceTypePrimary   = "primary"
	ServiceTypeFormation = "formation"
	ServiceTypeShared    = "shared"
)

Service types for GroupsIO services

View Source
const (
	// SourceAPI indicates the operation originated from our REST API
	SourceAPI = "api"

	// SourceWebhook indicates the operation originated from a Groups.io webhook
	SourceWebhook = "webhook"

	// SourceCommittee indicates the operation originated from committee-api events via NATS
	SourceCommittee = "committee"

	// SourceMock indicates the operation originated from mock/test infrastructure
	SourceMock = "mock"
)

Source constants define the origin of operations for business logic tracking

View Source
const (
	// KVBucketNameV1Mappings is the shared KV bucket used by v1 eventing consumers to track
	// processed entities (idempotency, created-vs-updated, tombstone markers for deletes).
	KVBucketNameV1Mappings = "v1-mappings"

	// KVBucketV1Objects is the NATS KV bucket that lfx-v1-sync-helper writes DynamoDB records into.
	KVBucketV1Objects = "v1-objects"

	// KVTombstoneMarker is the value written to v1-mappings after a successful delete,
	// preventing duplicate delete processing on consumer redelivery.
	KVTombstoneMarker = "!del"

	// KVMappingPrefixService is the v1-mappings key prefix for GroupsIO services.
	KVMappingPrefixService = "groupsio-service"
	// KVMappingPrefixSubgroup is the v1-mappings key prefix for GroupsIO subgroups (mailing lists).
	KVMappingPrefixSubgroup = "groupsio-subgroup"
	// KVMappingPrefixMember is the v1-mappings key prefix for GroupsIO members.
	KVMappingPrefixMember = "groupsio-member"
	// KVMappingPrefixSubgroupByGroupID is the v1-mappings reverse index: Groups.io group_id → subgroup UID.
	// Written by the subgroup handler so the member handler can resolve MailingListUID from group_id.
	KVMappingPrefixSubgroupByGroupID = "groupsio-subgroup-gid"
	// KVMappingPrefixSubgroupProject is the v1-mappings key that stores the project UID and slug for a
	// subgroup (mailing list). Written by the subgroup handler; read by the member handler so that
	// project_uid and project_slug can be included on indexed groupsio_member records.
	// Value format: "{project_uid}|{project_slug}"
	KVMappingPrefixSubgroupProject = "groupsio-subgroup-project"
	// KVMappingPrefixArtifact is the v1-mappings key prefix for GroupsIO artifacts.
	KVMappingPrefixArtifact = "groupsio-artifact"

	// KVMappingPrefixProjectBySFID is the v1-mappings forward index written by lfx-v1-sync-helper:
	// project.sfid.{sfid} → v2 project UID. Used to resolve the v1 project_id (SFID) to a v2 UID.
	KVMappingPrefixProjectBySFID = "project.sfid"

	// KVMappingPrefixCommitteeBySFID is the v1-mappings forward index written by lfx-v1-sync-helper:
	// committee.sfid.{sfid} → v2 committee UID. Used to resolve the v1 committee SFID to a v2 UID.
	KVMappingPrefixCommitteeBySFID = "committee.sfid"
)
View Source
const (
	// Indexing subjects for search and discovery
	IndexGroupsIOServiceSubject             = "lfx.index.groupsio_service"
	IndexGroupsIOServiceSettingsSubject     = "lfx.index.groupsio_service_settings"
	IndexGroupsIOMailingListSubject         = "lfx.index.groupsio_mailing_list"
	IndexGroupsIOMailingListSettingsSubject = "lfx.index.groupsio_mailing_list_settings"
	IndexGroupsIOMemberSubject              = "lfx.index.groupsio_member"
	IndexGroupsIOArtifactSubject            = "lfx.index.groupsio_artifact"

	// Committee event subjects from committee-api
	CommitteeMemberCreatedSubject = "lfx.committee-api.committee_member.created"
	CommitteeMemberDeletedSubject = "lfx.committee-api.committee_member.deleted"
	CommitteeMemberUpdatedSubject = "lfx.committee-api.committee_member.updated"
	CommitteeListMembersSubject   = "lfx.committee-api.list_members"

	// CommitteeGetProjectSubject is the request-reply subject for resolving a v2 committee UID
	// to its owning v2 project UID. Served by lfx-v2-committee-service (LFXV2-2472).
	// Request: JSON {"committee_uid":"<uuid>"}  Response: JSON {"project_uid":"<uuid>"} or {"error":"<msg>"}
	CommitteeGetProjectSubject = "lfx.committee-api.get_project"

	// Mailing list events from mailing-list-api
	MailingListCreatedSubject = "lfx.mailing-list-api.mailing_list_created"
	MailingListUpdatedSubject = "lfx.mailing-list-api.mailing_list_updated"

	// CommitteeMailingListChangedSubject is published when a mailing list CRUD operation
	// changes committee-related state (e.g. has_mailing_list flag).
	// Consumed by committee-api to update the committee document.
	CommitteeMailingListChangedSubject = "lfx.mailing-list-api.committee_mailing_list.changed"

	// AuthEmailToUsernameSubject resolves a primary email address to an LFX username via the auth service.
	AuthEmailToUsernameSubject = "lfx.auth-service.email_to_username"
)

NATS subject constants for message publishing

View Source
const (
	// Translation subjects — the entity type being translated.
	TranslationSubjectProject   = "project"
	TranslationSubjectCommittee = "committee"

	// Translation directions — which identifier space to translate from.
	TranslationDirectionV2ToV1 = "v2_to_v1"
	TranslationDirectionV1ToV2 = "v1_to_v2"
)
View Source
const (
	// TimestampFormat defines the standard timestamp format for the system (RFC3339)
	TimestampFormat = "2006-01-02T15:04:05Z07:00"

	// TimestampFormatName is the human-readable name for the timestamp format
	TimestampFormatName = "RFC3339"
)
View Source
const (
	ErrInvalidTimestampFormat = "invalid timestamp format, expected RFC3339 (2006-01-02T15:04:05Z07:00)"
	ErrEmptyTimestamp         = "timestamp cannot be empty"
)

Validation error messages

View Source
const (
	SubGroupCreatedEvent       = "created_subgroup"
	SubGroupDeletedEvent       = "deleted_subgroup"
	SubGroupMemberAddedEvent   = "added_member"
	SubGroupMemberRemovedEvent = "removed_member"
	SubGroupMemberBannedEvent  = "ban_members"
)

Webhook event types from Groups.io

View Source
const (
	WebhookMaxRetries     = 3
	WebhookRetryBaseDelay = 100  // milliseconds
	WebhookRetryMaxDelay  = 5000 // milliseconds
)

Webhook retry configuration

View Source
const AuthorizationHeader string = "authorization"

AuthorizationHeader is the header name for the authorization

View Source
const InviteAcceptedQueueGroup = "mailing-list-service-invite-accepted"

InviteAcceptedQueueGroup is the NATS queue group used by the mailing list service when subscribing to invite_accepted events. Using a unique queue group ensures only one mailing-list-service replica processes each event.

View Source
const InviteRoleMember = "Member"

InviteRoleMember is the invite-service role for mailing-list members who do not yet have an LFID.

View Source
const KVMemberLFIDInviteSentPrefix = "groupsio-member-lfid-invite-sent"

KVMemberLFIDInviteSentPrefix is the v1-mappings key prefix used to dedup LFID invites for mailing-list members. The full key is "<prefix>.<memberUID>". The key is created atomically with value "pending" before SendInvite is called (preventing concurrent duplicate sends); on success it is overwritten with the InviteUID; on failure it is purged so JetStream redelivery can retry.

View Source
const MailingListAPIQueue = "lfx-v2-mailing-list-api"

MailingListAPIQueue is the NATS queue group for mailing list service subscriptions

View Source
const (
	// RequestIDHeader is the HTTP header name for request ID
	RequestIDHeader = "X-Request-Id"
)

HTTP header constants

View Source
const (
	// ServiceName is the name of this service
	ServiceName = "mailing-list"
)

Service constants

View Source
const (
	WebhookSignatureHeader = "x-groupsio-signature"
)

Webhook header

View Source
const XOnBehalfOfHeader string = "x-on-behalf-of"

XOnBehalfOfHeader is the header name for the on behalf of principal

Variables

This section is empty.

Functions

func SourceDescription

func SourceDescription(source string) string

SourceDescription returns human-readable description of source behavior

func ValidSources

func ValidSources() []string

ValidSources returns list of all valid sources for documentation

func ValidateSource

func ValidateSource(source string) error

ValidateSource validates that the source is one of the allowed values

Types

type ContextKey

type ContextKey string

ContextKey is the unified type for all context keys to prevent type mismatches

const (
	// PrincipalContextID is the context key for the principal
	PrincipalContextID ContextKey = "principal"

	// AuthorizationContextID is the context key for the authorization
	AuthorizationContextID ContextKey = "authorization"

	// OnBehalfContextID is the context key for the on-behalf-of principal
	OnBehalfContextID ContextKey = "x-on-behalf-of"

	// RequestIDContextKey is the context key for request ID
	RequestIDContextKey ContextKey = "request-id"

	// GrpsIOWebhookBodyContextKey is the context key for raw GroupsIO webhook body
	GrpsIOWebhookBodyContextKey ContextKey = "grpsio-webhook-body"
)

Context keys for various middleware and service contexts

Jump to

Keyboard shortcuts

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