Documentation
¶
Index ¶
- Constants
- Variables
- func FormatEndpointError(err error) error
- func FormatError(err error) string
- type BridgePublisher
- type CreateDeliveryInput
- type CreateEndpointInput
- type Delivery
- type DeliveryUpdate
- type Endpoint
- type EndpointRecord
- type PostgresStore
- func (s *PostgresStore) CreateDeliveryTx(ctx context.Context, tx pgx.Tx, input CreateDeliveryInput) (Delivery, error)
- func (s *PostgresStore) CreateEndpoint(ctx context.Context, input CreateEndpointInput) (EndpointRecord, error)
- func (s *PostgresStore) DeleteEndpoint(ctx context.Context, id int64) error
- func (s *PostgresStore) GetDelivery(ctx context.Context, id int64) (Delivery, error)
- func (s *PostgresStore) GetEndpoint(ctx context.Context, id int64) (EndpointRecord, error)
- func (s *PostgresStore) ListDeliveries(ctx context.Context, endpointID int64, limit int) ([]Delivery, error)
- func (s *PostgresStore) ListEnabledEndpointsForEvent(ctx context.Context, eventName string) ([]EndpointRecord, error)
- func (s *PostgresStore) ListEndpoints(ctx context.Context) ([]EndpointRecord, error)
- func (s *PostgresStore) UpdateDelivery(ctx context.Context, input DeliveryUpdate) error
- func (s *PostgresStore) UpdateEndpoint(ctx context.Context, id int64, input UpdateEndpointInput) (EndpointRecord, error)
- func (s *PostgresStore) UpdateEndpointSecret(ctx context.Context, id int64, encrypted string) error
- type Service
- func (s *Service) CreateEndpoint(ctx context.Context, actor identity.Actor, input CreateEndpointInput) (Endpoint, error)
- func (s *Service) DecryptEndpointSecret(stored string) (string, error)
- func (s *Service) DeleteEndpoint(ctx context.Context, actor identity.Actor, id int64) error
- func (s *Service) Fanout(ctx context.Context, envelope appevents.Envelope)
- func (s *Service) ListDeliveries(ctx context.Context, actor identity.Actor, endpointID int64, limit int) ([]Delivery, error)
- func (s *Service) ListEndpoints(ctx context.Context, actor identity.Actor) ([]Endpoint, error)
- func (s *Service) MaybeMigrateSecret(stored string) (encrypted string, ok bool)
- func (s *Service) UpdateEndpoint(ctx context.Context, actor identity.Actor, id int64, input UpdateEndpointInput) (Endpoint, error)
- func (s *Service) WithAllowHTTP(allow bool) *Service
- func (s *Service) WithCipher(c *crypto.OptionCipher) *Service
- type Store
- type TxEnqueuer
- type UpdateEndpointInput
Constants ¶
View Source
const ( // 投递状态复用 outbox 词表。 StatusQueued = outbox.StatusQueued StatusSending = outbox.StatusSending StatusSent = outbox.StatusSent StatusFailed = outbox.StatusFailed StatusSkipped = outbox.StatusSkipped StatusDead = outbox.StatusDead // DefaultMaxAttempts River + 本地 attempt 预算。 DefaultMaxAttempts = 5 )
Variables ¶
Functions ¶
func FormatEndpointError ¶
func FormatError ¶
Types ¶
type BridgePublisher ¶
BridgePublisher 在 extension runtime 发事件后扇出 webhook(不改动插件投递语义)。
type CreateDeliveryInput ¶
type CreateEndpointInput ¶
type Delivery ¶
type Delivery struct {
ID int64 `json:"id"`
EndpointID int64 `json:"endpointId"`
EventName string `json:"eventName"`
EventID string `json:"eventId,omitempty"`
CorrelationID string `json:"correlationId,omitempty"`
Payload json.RawMessage `json:"payload,omitempty"`
Status string `json:"status"`
AttemptCount int `json:"attemptCount"`
HTTPStatus int `json:"httpStatus,omitempty"`
ResponseSnippet string `json:"responseSnippet,omitempty"`
Reason string `json:"reason,omitempty"`
ErrorSummary string `json:"errorSummary,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CompletedAt *time.Time `json:"completedAt,omitempty"`
}
type DeliveryUpdate ¶
type Endpoint ¶
type Endpoint struct {
ID int64 `json:"id"`
Name string `json:"name"`
TargetURL string `json:"targetUrl"`
SecretMasked string `json:"secretMasked"`
// HasSecret 表示是否已配置签名密钥(不回传明文)。
HasSecret bool `json:"hasSecret"`
Events []string `json:"events"`
Enabled bool `json:"enabled"`
Description string `json:"description,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
Endpoint 是管理员配置的出站订阅。
func PublicEndpoint ¶
func PublicEndpoint(record EndpointRecord) Endpoint
PublicEndpoint 去掉 secret 明文后再返回 API。
type EndpointRecord ¶
EndpointRecord 内部行(含 secret 明文,仅 store/worker 使用)。
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
func NewPostgresStore ¶
func NewPostgresStore(pool *pgxpool.Pool) *PostgresStore
func (*PostgresStore) CreateDeliveryTx ¶
func (s *PostgresStore) CreateDeliveryTx(ctx context.Context, tx pgx.Tx, input CreateDeliveryInput) (Delivery, error)
func (*PostgresStore) CreateEndpoint ¶
func (s *PostgresStore) CreateEndpoint(ctx context.Context, input CreateEndpointInput) (EndpointRecord, error)
func (*PostgresStore) DeleteEndpoint ¶
func (s *PostgresStore) DeleteEndpoint(ctx context.Context, id int64) error
func (*PostgresStore) GetDelivery ¶
func (*PostgresStore) GetEndpoint ¶
func (s *PostgresStore) GetEndpoint(ctx context.Context, id int64) (EndpointRecord, error)
func (*PostgresStore) ListDeliveries ¶
func (*PostgresStore) ListEnabledEndpointsForEvent ¶
func (s *PostgresStore) ListEnabledEndpointsForEvent(ctx context.Context, eventName string) ([]EndpointRecord, error)
func (*PostgresStore) ListEndpoints ¶
func (s *PostgresStore) ListEndpoints(ctx context.Context) ([]EndpointRecord, error)
func (*PostgresStore) UpdateDelivery ¶
func (s *PostgresStore) UpdateDelivery(ctx context.Context, input DeliveryUpdate) error
func (*PostgresStore) UpdateEndpoint ¶
func (s *PostgresStore) UpdateEndpoint(ctx context.Context, id int64, input UpdateEndpointInput) (EndpointRecord, error)
func (*PostgresStore) UpdateEndpointSecret ¶
UpdateEndpointSecret 懒迁移:仅更新 secret 列(明文 → 密文)。
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service 管理端点配置,并把 core observe 事件扇出为 webhook 投递。
func NewService ¶
func NewService(store Store, pool *pgxpool.Pool, jobs TxEnqueuer) *Service
func (*Service) CreateEndpoint ¶
func (*Service) DecryptEndpointSecret ¶
DecryptEndpointSecret 投递时解密 secret;错误密钥 fail closed。
func (*Service) DeleteEndpoint ¶
func (*Service) ListDeliveries ¶
func (*Service) ListEndpoints ¶
func (*Service) MaybeMigrateSecret ¶
MaybeMigrateSecret 若 stored 为明文且 cipher 启用,返回应写回的密文。
func (*Service) UpdateEndpoint ¶
func (*Service) WithAllowHTTP ¶
WithAllowHTTP 开发/测试可显式允许 http webhook 目标(生产勿开)。
func (*Service) WithCipher ¶
WithCipher 注入 AES-GCM 加密器用于 webhook secret 静态加密。
type Store ¶
type Store interface {
ListEndpoints(ctx context.Context) ([]EndpointRecord, error)
GetEndpoint(ctx context.Context, id int64) (EndpointRecord, error)
CreateEndpoint(ctx context.Context, input CreateEndpointInput) (EndpointRecord, error)
UpdateEndpoint(ctx context.Context, id int64, input UpdateEndpointInput) (EndpointRecord, error)
DeleteEndpoint(ctx context.Context, id int64) error
CreateDeliveryTx(ctx context.Context, tx pgx.Tx, input CreateDeliveryInput) (Delivery, error)
GetDelivery(ctx context.Context, id int64) (Delivery, error)
UpdateDelivery(ctx context.Context, input DeliveryUpdate) error
ListDeliveries(ctx context.Context, endpointID int64, limit int) ([]Delivery, error)
ListEnabledEndpointsForEvent(ctx context.Context, eventName string) ([]EndpointRecord, error)
}
Store 持久化端点与投递记录。
type TxEnqueuer ¶
type TxEnqueuer interface {
EnqueueTx(context.Context, pgx.Tx, river.JobArgs, supportjobs.EnqueueOptions) (*rivertype.JobInsertResult, error)
}
Click to show internal directories.
Click to hide internal directories.