constants

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: May 5, 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 (
	// KVBucketNameGroupsIOServices is the name of the KV bucket for services.
	KVBucketNameGroupsIOServices = "groupsio-services"

	// KVBucketNameGroupsIOServiceSettings is the name of the KV bucket for service settings.
	KVBucketNameGroupsIOServiceSettings = "groupsio-service-settings"

	// KVBucketNameGroupsIOMailingLists is the name of the KV bucket for mailing lists.
	KVBucketNameGroupsIOMailingLists = "groupsio-mailing-lists"

	// KVBucketNameGroupsIOMailingListSettings is the name of the KV bucket for mailing list settings.
	KVBucketNameGroupsIOMailingListSettings = "groupsio-mailing-list-settings"

	// KVBucketNameGroupsIOMembers is the name of the KV bucket for members.
	KVBucketNameGroupsIOMembers = "groupsio-members"

	// Lookup key patterns for unique constraints
	// KVLookupGroupsIOServicePrefix is the key pattern for unique constraint lookups
	KVLookupGroupsIOServicePrefix = "lookup/groupsio-services/%s"

	// Service secondary index key patterns for external GroupsIO IDs
	// KVLookupGroupsIOServiceByGroupIDPrefix is the key pattern for GroupID index (lookup by Groups.io group ID)
	KVLookupGroupsIOServiceByGroupIDPrefix = "lookup/groupsio-service-groupid/%d"
	// KVLookupGroupsIOServiceByProjectUIDPrefix is the key pattern for ProjectUID index (lookup by ProjectUID)
	KVLookupGroupsIOServiceByProjectUIDPrefix = "lookup/groupsio-service-projectuid/%s"

	// Mailing list secondary index key patterns
	// KVLookupMailingListServicePrefix is the key pattern for service index
	KVLookupGroupsIOMailingListServicePrefix = "lookup/groupsio-mailing-list-service/%s"
	// KVLookupMailingListCommitteePrefix is the key pattern for committee index
	KVLookupGroupsIOMailingListCommitteePrefix = "lookup/groupsio-mailing-list-committee/%s"
	// KVLookupMailingListProjectPrefix is the key pattern for project index
	KVLookupGroupsIOMailingListProjectPrefix = "lookup/groupsio-mailing-list-project/%s"
	// KVLookupMailingListConstraintPrefix is the key pattern for uniqueness constraint (hashed service_id + group_name)
	KVLookupGroupsIOMailingListConstraintPrefix = "lookup/groupsio-mailing-list-name/%s"
	// KVLookupGroupsIOMailingListBySubgroupIDPrefix is the key pattern for SubgroupID index (lookup by Groups.io subgroup ID)
	KVLookupGroupsIOMailingListBySubgroupIDPrefix = "lookup/groupsio-mailing-list-subgroupid/%d"

	// Member lookup key patterns
	// KVLookupGroupsIOMemberPrefix is the key pattern for member unique constraint lookups (email per mailing list)
	KVLookupGroupsIOMemberPrefix = "lookup/groupsio-members/%s"
	// KVLookupGroupsIOMemberConstraintPrefix is the key pattern for member uniqueness constraint (mailing_list_uid + email)
	KVLookupGroupsIOMemberConstraintPrefix = "lookup/groupsio-member-email/%s"
	// KVLookupGroupsIOMemberByMemberIDPrefix is the key pattern for GroupsIOMemberID index (lookup by Groups.io member ID)
	KVLookupGroupsIOMemberByMemberIDPrefix = "lookup/groupsio-member-memberid/%d"
	// KVLookupGroupsIOMemberByGroupIDPrefix is the key pattern for GroupsIOGroupID index (lookup by Groups.io group ID)
	KVLookupGroupsIOMemberByGroupIDPrefix = "lookup/groupsio-member-groupid/%d"

	// 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"

	// Key prefixes for bucket detection
	// GroupsIOMailingListKeyPrefix is the common prefix for all mailing list related keys
	GroupsIOMailingListKeyPrefix = "lookup/groupsio-mailing-list/"
	// GroupsIOServiceLookupKeyPrefix is the prefix for service lookup keys
	GroupsIOServiceLookupKeyPrefix = "lookup/groupsio-services/"
	// GroupsIOMemberLookupKeyPrefix is the prefix for member lookup keys
	GroupsIOMemberLookupKeyPrefix = "lookup/groupsio-members/"
)
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"

	// 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"
)

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 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