Documentation
¶
Overview ¶
Package api serves the client and admin surfaces through policy-classed registrations, plus a fixed loopback health endpoint.
Index ¶
- Constants
- Variables
- func BackfillQuota(wait time.Duration) error
- func Busy(wait time.Duration) error
- func InProgress(wait time.Duration) error
- func NewAdminHandler(d AdminDeps) http.Handler
- func NewClientHandler(d ClientDeps) http.Handler
- func NewHealthHandler(ready func() bool) http.Handler
- func RateLimited(wait time.Duration) error
- func WellFormedKey(key string) bool
- type AdminDeps
- type AdminEvents
- type AdminService
- type AdminStatus
- type Auditor
- type Authenticator
- type BackfillAnchor
- type ChatEntry
- type ClientChatView
- type ClientCounts
- type ClientDeps
- type ClientService
- type ClientView
- type MediaDeps
- type MediaFetch
- type MediaPause
- type MediaService
- type MediaSpool
- type ReadArchive
- type ReadEvent
- type ReadLimits
- type Request
- type SendReply
- type SendRequest
- type SendService
- type Sent
Constants ¶
View Source
const ( DefaultReadsPerMinute = 600 DefaultSearchesPerMinute = 60 )
Variables ¶
View Source
var ( ErrAlreadyPaired error = &codedError{status: http.StatusConflict, code: "already_paired"} ErrAlreadyConnected error = &codedError{status: http.StatusConflict, code: "already_connected"} ErrNotPaired error = &codedError{status: http.StatusConflict, code: "not_paired"} ErrOwnerPhoneMissing error = &codedError{status: http.StatusConflict, code: "owner_phone_missing"} ErrOwnerMismatch error = &codedError{status: http.StatusConflict, code: "owner_mismatch"} ErrRateLimited error = &codedError{status: http.StatusTooManyRequests, code: codeRateLimited} ErrPairFailed error = &codedError{status: http.StatusBadGateway, code: "pair_failed"} ErrBackfillNoAnchor error = &codedError{status: http.StatusUnprocessableEntity, code: codeBackfillNoAnchor} )
View Source
var ( ErrMediaExpired error = errMediaExpired ErrMediaTooLarge error = errMediaTooLarge ErrMediaUnsupported error = errMediaUnsupported ErrMediaFailed error = errMediaFailed )
View Source
var ( ErrNotFound error = errNotFound ErrBusy error = errBusy ErrKeyReused error = &codedError{status: http.StatusUnprocessableEntity, code: codeKeyReused} ErrFirstContact error = &codedError{status: http.StatusForbidden, code: codeFirstContact} ErrNotConnected error = &codedError{status: http.StatusServiceUnavailable, code: codeNotConnected, retryAfter: notConnected} ErrSendRejected error = &codedError{status: http.StatusBadGateway, code: codeSendRejected} ErrSendOutcomeUnknown error = &codedError{status: http.StatusGatewayTimeout, code: codeSendOutcomeUnknown} )
View Source
var (
ErrClientNotFound error = &codedError{status: http.StatusNotFound, code: codeNotFound}
)
Functions ¶
func BackfillQuota ¶ added in v1.0.0
func InProgress ¶ added in v1.0.0
func NewAdminHandler ¶
func NewClientHandler ¶
func NewClientHandler(d ClientDeps) http.Handler
func NewHealthHandler ¶
func RateLimited ¶ added in v1.0.0
func WellFormedKey ¶ added in v1.0.0
Types ¶
type AdminDeps ¶
type AdminDeps struct {
Credential policy.AdminCredential
Metrics *metrics.Registry
Service AdminService
Events AdminEvents
Now func() time.Time
}
type AdminEvents ¶ added in v0.2.0
type AdminEvents interface {
AdminMutation(action, outcome string)
AdminAuthFailure()
}
type AdminService ¶ added in v0.2.0
type AdminService interface {
Status(ctx context.Context) (AdminStatus, error)
Pair(ctx context.Context) (code string, err error)
Reconnect(ctx context.Context) error
Backfill(g policy.AdminGrant, ctx context.Context, chat policy.CanonicalChat, count int, anchor BackfillAnchor) (requestID string, err error)
PauseMedia(paused bool)
ClientService
}
type AdminStatus ¶ added in v0.2.0
type AdminStatus struct {
State string
Reason string
Paired bool
Chats int64
Messages int64
BlobsPending int64
BlobsQuarantined int64
InboxBacklog int64
InboxQuarantined int64
BackfillsToday int64
MediaRefsLive int64
MediaRefsExpired int64
RevokeTombstones int64
Downloads bool
MediaPaused bool
Clients ClientCounts
LastIngest time.Time
Version string
}
type Authenticator ¶
type BackfillAnchor ¶ added in v1.3.0
type BackfillAnchor uint8
const ( BackfillOldest BackfillAnchor = iota BackfillNewest )
type ChatEntry ¶ added in v0.3.0
type ChatEntry struct {
Chat policy.CanonicalChat
Ref string
Name string
}
type ClientChatView ¶ added in v0.3.0
type ClientChatView struct {
Chat policy.CanonicalChat
Known bool
Name string
}
type ClientCounts ¶ added in v0.3.0
type ClientDeps ¶
type ClientDeps struct {
Authenticator Authenticator
Metrics *metrics.Registry
Now func() time.Time
Archive ReadArchive
Audit Auditor
Session func() string
Cursors *cursor.Sealer
Refs *cursor.Sealer
Limits ReadLimits
Sender SendService
SendRejected func(reason string)
AuditFailed func(action string, err error)
Media *MediaDeps
}
type ClientService ¶ added in v0.3.0
type ClientService interface {
CreateClient(ctx context.Context, spec policy.ClientSpec) (view ClientView, credential string, err error)
Clients(ctx context.Context) ([]ClientView, error)
Client(ctx context.Context, id string) (ClientView, error)
RevokeClient(ctx context.Context, id string) (ClientView, error)
Chats(ctx context.Context, match string, limit int) (chats []ChatEntry, truncated bool, err error)
}
type ClientView ¶ added in v0.3.0
type MediaFetch ¶ added in v1.2.0
type MediaFetch struct {
Chat policy.CanonicalChat
ID string
Sender policy.CanonicalChat
Kind string
Variant string
Declared int64
}
type MediaPause ¶ added in v1.2.0
type MediaPause struct {
// contains filtered or unexported fields
}
func (*MediaPause) Paused ¶ added in v1.2.0
func (p *MediaPause) Paused() bool
func (*MediaPause) Set ¶ added in v1.2.0
func (p *MediaPause) Set(paused bool)
type MediaService ¶ added in v1.2.0
type MediaService interface {
Precheck(declared int64) error
Fetch(ctx context.Context, ref scoped.SealedRef, req MediaFetch) (MediaSpool, error)
}
type MediaSpool ¶ added in v1.2.0
type ReadArchive ¶ added in v0.3.0
type ReadArchive interface {
Chats(g policy.ReadGrant, ctx context.Context, pos scoped.ChatPosition, limit int) (scoped.ChatPage, error)
Chat(g policy.ReadGrant, ctx context.Context, ref string) (scoped.Chat, bool, error)
Messages(g policy.ReadGrant, ctx context.Context, ref string, pos scoped.MessagePosition, dir scoped.Direction, limit int) (scoped.MessagePage, bool, error)
Message(g policy.ReadGrant, ctx context.Context, chat policy.CanonicalChat, id string, sender policy.CanonicalChat) (scoped.Message, bool, error)
Changes(g policy.ReadGrant, ctx context.Context, ref string, pos scoped.ChangePosition, limit int) (scoped.ChangePage, bool, error)
Search(g policy.ReadGrant, ctx context.Context, query scoped.Query, ref string, pos scoped.SearchPosition, limit int) (scoped.SearchPage, bool, error)
Attachment(g policy.ReadGrant, ctx context.Context, chat policy.CanonicalChat, id string, sender policy.CanonicalChat, now time.Time) (scoped.Attachment, bool, error)
}
type ReadLimits ¶ added in v0.3.0
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func (*Request) DecodeJSON ¶ added in v0.2.0
type SendReply ¶ added in v1.0.0
type SendReply struct {
ID string
Sender policy.CanonicalChat
Seq int64
Text string
}
type SendRequest ¶ added in v1.0.0
type SendService ¶ added in v1.0.0
type SendService interface {
Send(g policy.WriteGrant, ctx context.Context, req SendRequest) (Sent, error)
}
type Sent ¶ added in v1.0.0
type Sent struct {
Chat policy.CanonicalChat
ID string
Sender policy.CanonicalChat
Replayed bool
}
Sent reports a replay on a stored failure as well, beside the error.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.