Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultOrgID() string
- func OTelCollectorOTLPGRPCEndpoint(namespace string) string
- func OTelCollectorOTLPHTTPEndpoint(namespace string) string
- func OTelCollectorServiceName() string
- type AppError
- type BaseEvent
- type DomainEvent
- type EventBus
- type EventHandler
- type InMemoryEventBus
Constants ¶
const ( // PostgresReleaseName 은 플랫폼이 설치하는 PostgreSQL 릴리스다. PostgresReleaseName = "nullus-postgresql" // MinIOReleaseName 은 플랫폼이 설치하는 MinIO 릴리스다. MinIOReleaseName = "nullus-minio" )
플랫폼이 설치하는 공유 인프라의 Helm 릴리스 이름.
여기 있는 이유는 두 모듈이 같은 이름을 봐야 하기 때문이다 — stack 은 이 이름으로 차트를 설치하고 접속 정보를 안내하고, admin 의 시크릿 회전은 같은 이름으로 워크로드를 재시작한다. 모듈끼리 서로의 internal 을 참조할 수 없으므로 이름의 단일 출처를 shared 에 둔다.
Helm 은 릴리스명을 그대로 Service 이름에 쓰므로, 이 값이 곧 클러스터 안의 접속 주소이기도 하다. 한쪽만 바꾸면 다른 쪽이 조용히 어긋난다.
const ( // OTelCollectorReleaseName 은 게이트웨이 수집기의 릴리스명이다. // // 차트 이름(opentelemetry-collector)을 그대로 쓰지 않는 이유는 추적 계층 // 단계가 같은 차트를 설치할 수 있어 릴리스명이 충돌하기 때문이다. OTelCollectorReleaseName = "otel-collector" // OTelAgentReleaseName 은 노드마다 서는 로그 수집 에이전트의 릴리스명이다. OTelAgentReleaseName = "otel-agent" // OTLP 수신 포트. 차트 기본값이며 애플리케이션이 붙는 지점이다. OTelCollectorOTLPGRPCPort = 4317 OTelCollectorOTLPHTTPPort = 4318 )
OpenTelemetry Collector 의 이름과 주소 규칙.
stack 은 이 이름으로 차트를 설치하고, cicd 는 배포하는 앱에 "어디로 텔레메트리를 보낼지" 를 넣어 준다. 두 모듈이 같은 주소를 봐야 하므로 규칙을 여기 둔다 — 한쪽이 문자열을 흉내 내면 차트 이름이 바뀔 때 조용히 어긋난다.
const DefaultStackNamespace = "nullus"
DefaultStackNamespace 는 스택 네임스페이스가 정해지지 않았을 때의 기본값이다.
const SeededDefaultOrgID = "11111111-1111-1111-1111-111111111111"
SeededDefaultOrgID 는 시드 마이그레이션이 만드는 기본 조직이다.
인증이 꺼진 개발 모드에는 principal 도 헤더도 없어 폴백 조직이 필요하다. 이 값이 실제 organizations 행과 달라지면 쓰기 경로는 stacks_org_id_fkey FK 위반으로 실패하고, 읽기 경로는 빈 결과만 돌려준다.
이전에 쓰이던 00000000-0000-0000-0000-000000000001 은 어떤 마이그레이션에도 존재하지 않는 유령 조직이었다.
Variables ¶
var ( ErrNotFound = NewAppError("NOT_FOUND", 404, "Resource not found", "", false) ErrForbidden = NewAppError("FORBIDDEN", 403, "Access denied", "", false) ErrValidation = NewAppError("VALIDATION_ERROR", 422, "Validation failed", "", false) )
Common errors.
Functions ¶
func DefaultOrgID ¶
func DefaultOrgID() string
DefaultOrgID 는 폴백 조직 ID 를 반환한다. 시드 조직 ID 가 다른 환경에서는 NULLUS_DEFAULT_ORG_ID 로 덮어쓴다.
func OTelCollectorOTLPGRPCEndpoint ¶
OTelCollectorOTLPGRPCEndpoint 는 애플리케이션이 OTLP/gRPC 로 보낼 주소다.
func OTelCollectorOTLPHTTPEndpoint ¶
OTelCollectorOTLPHTTPEndpoint 는 애플리케이션이 OTLP/HTTP 로 보낼 주소다.
func OTelCollectorServiceName ¶
func OTelCollectorServiceName() string
OTelCollectorServiceName 은 수집기 Service 이름이다. 차트의 fullname 규칙이 "<릴리스>-<차트>" 라 릴리스명만으로는 맞지 않는다.
Types ¶
type AppError ¶
type AppError struct {
Code string `json:"code"`
HTTPStatus int `json:"http_status"`
Message string `json:"message"`
Detail string `json:"detail,omitempty"`
Retryable bool `json:"retryable"`
TraceID string `json:"trace_id,omitempty"`
}
AppError represents a structured application error.
func NewAppError ¶
NewAppError creates a new AppError.
type BaseEvent ¶
type BaseEvent struct {
Name string `json:"name"`
Timestamp time.Time `json:"occurred_at"`
AggregateId string `json:"aggregate_id"`
}
BaseEvent provides a base implementation of DomainEvent.
func (BaseEvent) AggregateID ¶
func (BaseEvent) OccurredAt ¶
type DomainEvent ¶
DomainEvent represents an event that occurred in the domain.
type EventBus ¶
type EventBus interface {
Publish(event DomainEvent) error
Subscribe(eventName string, handler EventHandler)
}
EventBus defines the interface for publishing and subscribing to domain events.
type EventHandler ¶
type EventHandler func(event DomainEvent) error
EventHandler is a function that handles a domain event.
type InMemoryEventBus ¶
type InMemoryEventBus struct {
// contains filtered or unexported fields
}
InMemoryEventBus is an in-memory implementation of EventBus.
func NewInMemoryEventBus ¶
func NewInMemoryEventBus() *InMemoryEventBus
NewInMemoryEventBus creates a new InMemoryEventBus.
func (*InMemoryEventBus) Publish ¶
func (b *InMemoryEventBus) Publish(event DomainEvent) error
Publish sends an event to all registered handlers.
func (*InMemoryEventBus) Subscribe ¶
func (b *InMemoryEventBus) Subscribe(eventName string, handler EventHandler)
Subscribe registers a handler for a specific event name.