core

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAbortPipeline = errors.New("abort pipeline")

Functions

This section is empty.

Types

type ConsumerRequestContext added in v0.3.0

type ConsumerRequestContext interface {
	ContextCarrier
	EventBusCarrier

	EventName() string
	Payload() []byte
}

ConsumerRequestContext - 이벤트 컨슈머 전용 컨텍스트

type Container added in v0.4.1

type Container interface {
	Resolve(t reflect.Type) (any, error)
}

Container는 CustomTransport에서 DI에 접근할 때 사용하는 퍼사드입니다.

type ContextCarrier added in v0.2.4

type ContextCarrier interface {
	Context() context.Context
}

type ControllerContext added in v0.3.2

type ControllerContext interface {
	Get(key string) (any, bool)
}

ControllerContext - 컨트롤러 전용 컨텍스트 뷰 - ExecutionContext의 읽기 전용 퍼사드 - 인터셉터에서 주입한 값을 컨트롤러에서 참조하는 공식 통로

type CustomTransport added in v0.4.1

type CustomTransport interface {
	// Init은 DI 컨테이너가 준비된 후 호출됩니다.
	Init(container Container) error
	// Start는 Init 이후 별도 고루틴에서 호출됩니다.
	Start() error
	// Stop은 정상 종료 시 호출됩니다.
	Stop(ctx context.Context) error
}

CustomTransport는 Spine HTTP 파이프라인 외부에서 독립 실행되는 전송 방식의 계약입니다.

type EventBus added in v0.3.9

type EventBus interface {
	Publish(events ...publish.DomainEvent)
	Drain() []publish.DomainEvent
}

EventBus는 도메인 이벤트를 수집했다가 실행 후 한 번에 방출하기 위한 최소 계약입니다.

type EventBusCarrier added in v0.3.0

type EventBusCarrier interface {
	EventBus() EventBus
}

type ExecutionContext added in v0.1.3

type ExecutionContext interface {
	ContextCarrier
	EventBusCarrier

	Method() string
	Path() string
	Params() map[string]string
	Header(name string) string
	PathKeys() []string
	Queries() map[string][]string
	Set(key string, value any)
	Get(key string) (any, bool)
}

ExecutionContext - 파이프라인과 라우터 전용 - HTTP 전송 실행 흐름에서만 사용

type HandlerMeta added in v0.1.5

type HandlerMeta struct {
	// 컨트롤러 타입(Container의 Resolve 대상)
	ControllerType reflect.Type
	// 호출할 메서드 이름
	Method reflect.Method
	// 라우트에 선언된 경로 매개변수 키의 순서
	PathKeys []string
	// 핸들러에 적용된 인터셉터
	Interceptors []Interceptor
}

HandlerMeta는 실제로 실행할 핸들러에 대한 메타데이터입니다.

type HttpRequestContext added in v0.3.0

type HttpRequestContext interface {
	ContextCarrier
	EventBusCarrier

	// 개별 접근
	Param(name string) string
	Query(name string) string
	Header(name string) string

	// 전체 뷰 접근
	Params() map[string]string
	Queries() map[string][]string
	Headers() map[string][]string

	// 요청 본문
	Bind(out any) error

	// 멀티파트
	MultipartForm() (*multipart.Form, error)
}

HttpRequestContext - HTTP 전용 컨텍스트 계약

type Interceptor added in v0.1.5

type Interceptor interface {
	/*
		PreHandle은 컨트롤러 호출 전에 실행된다.
		여기서 오류를 반환하면 실행을 중단한다.
	*/
	PreHandle(ctx ExecutionContext, meta HandlerMeta) error

	/*
		PostHandle은 ReturnValueHandler 처리 후 실행된다.
		실패해도 전체 파이프라인 실패로 만들지 않는다.
	*/
	PostHandle(ctx ExecutionContext, meta HandlerMeta)

	/*
		BeforeResponse는 핸들러 실행과 후속 훅이 끝난 뒤, 응답을 쓰기 전에 실행된다.
		PreHandle을 성공한 Interceptor만 역순으로 호출된다.
		executionErr는 이 시점까지 발생한 최종 오류이며, 구현체가 반환한 오류는
		최종 실행 오류에 포함된다.
	*/
	BeforeResponse(ctx ExecutionContext, meta HandlerMeta, executionErr error) error

	/*
		AfterCompletion은 성공/실패와 관계없이 마지막에 호출된다.
		err는 파이프라인 실행 중 발생한 최종 오류
	*/
	AfterCompletion(ctx ExecutionContext, meta HandlerMeta, err error)
}

Interceptor는 실행 흐름의 횡단 관심사를 처리하는 계약이다. 컨트롤러, Invoker, Resolver는 Interceptor를 몰라야 한다.

type ResponseWriter added in v0.1.3

type ResponseWriter interface {
	// 헤더 조작
	SetHeader(key, value string)
	AddHeader(key, value string)

	// 응답이 이미 커밋(헤더/바디 작성 시작)되었는지 여부
	IsCommitted() bool

	// 상태 코드만 기록(응답 본문 없음)
	WriteStatus(status int) error

	// 응답 본문과 상태 코드 기록
	WriteJSON(status int, value any) error
	WriteString(status int, value string) error
	WriteBytes(status int, value []byte) error
}

ResponseWriter는 전송 구현(Echo, net/http 등)에 의존하지 않는 Spine의 응답 출력 계약이다. 실제 구현은 어댑터 계층에서 제공한다.

type WebSocketContext added in v0.4.1

type WebSocketContext interface {
	ExecutionContext

	ConnID() string
	MessageType() int
	Payload() []byte
}

WebSocketContext - WebSocket 전용 ExecutionContext 확장

type WebSocketHandshakeContext added in v0.5.1

type WebSocketHandshakeContext interface {
	WebSocketRequestContext
}

WebSocketHandshakeContext는 HTTP upgrade 전에 인증/인가에 사용할 요청 뷰입니다.

type WebSocketHandshakeInterceptor added in v0.5.1

type WebSocketHandshakeInterceptor interface {
	PreHandshake(ctx WebSocketHandshakeContext, meta HandlerMeta) error
}

WebSocketHandshakeInterceptor는 선택적 WebSocket handshake 사전 처리 계약입니다. 구현한 인터셉터만 연결 슬롯 예약과 HTTP upgrade 전에 호출됩니다. 기존 Interceptor의 PreHandle은 메시지마다 기존 시점에 계속 호출되므로 호출 횟수와 트랜잭션 의미가 바뀌지 않습니다.

type WebSocketMessageContext added in v0.5.1

type WebSocketMessageContext interface {
	WebSocketContext
	WebSocketRequestContext
}

WebSocketMessageContext는 메시지 처리와 원래 handshake 요청 정보를 함께 제공합니다.

type WebSocketRequestContext added in v0.5.1

type WebSocketRequestContext interface {
	ContextCarrier

	Path() string
	Header(name string) string
	Headers() map[string][]string
	Query(name string) string
	Queries() map[string][]string
	Cookie(name string) (string, bool)
	Cookies() map[string]string
	RemoteAddr() string
	Host() string
	RequestURI() string
}

WebSocketRequestContext - WebSocket upgrade 요청에서 보존한 불변 요청 정보 뷰 - WebSocketContext와 별도인 추가 계약이므로 기존 사용자 구현을 깨지 않습니다.

Jump to

Keyboard shortcuts

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