Documentation ¶
Index ¶
- Variables
- func BelongsToSameChannel(msgs []Message) bool
- func IsStorageNonFatalError(err error) bool
- type AckHandle
- type CIDR
- type Channel
- type ChannelID
- type ChannelProvider
- type Duration
- type ErrorWithCode
- type JwtAlg
- type JwtAud
- type JwtExp
- type JwtIss
- type JwtJti
- type JwtStorage
- type Message
- type MessageID
- type MessageLocator
- type PubSubStorage
- type Regex
- type Storage
- type StorageID
- type SubscriberID
- type SubscriberLocator
- type SystemClock
- type TemplateString
- type TemplateStringEnv
- type TemplateStrings
- type Time
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidChannel : Given channel is not permitted in configuration ErrInvalidChannel = NewErrorWithCode("dsps.storage.invalid-channel") // ErrSubscriptionNotFound : Subscriber expired (due to infrequent access less than expire setting) or not created ErrSubscriptionNotFound = NewErrorWithCode("dsps.storage.subscription-not-found") // ErrMalformedAckHandle : Failed to decode/decrypt given AckHandle ErrMalformedAckHandle = NewErrorWithCode("dsps.storage.ack-handle-malformed") // ErrMalformedMessageJSON : Given message content is not valid JSON ErrMalformedMessageJSON = NewErrorWithCode("dsps.storage.message-json-malformed") )
var PrivateCIDRs []CIDR
PrivateCIDRs is a list of private networks, link local, and loopback addresses.
Functions ¶
func BelongsToSameChannel ¶
BelongsToSameChannel returns false if messages belongs to various channels
func IsStorageNonFatalError ¶
IsStorageNonFatalError returns true if given error does not indicate storage system error
Types ¶
type AckHandle ¶
type AckHandle struct { SubscriberLocator Handle string }
AckHandle is an token to remove received (acknowledged) messages from a subscriber.
type CIDR ¶
type CIDR struct {
// contains filtered or unexported fields
}
CIDR is IPNet wrapper struct
func (CIDR) MarshalJSON ¶
MarshalJSON method for configuration marshal/unmarshal
func (*CIDR) UnmarshalJSON ¶
UnmarshalJSON method for configuration marshal/unmarshal
type Channel ¶
type Channel interface { Expire() Duration // Note that this method does not check revocation list. ValidateJwt(ctx context.Context, jwt string) error SendOutgoingWebhook(ctx context.Context, msg Message) error }
Channel struct holds all objects/information of a channel
type ChannelID ¶
type ChannelID string
ChannelID is ID of the PubSub channel, system-wide unique value
func ParseChannelID ¶
ParseChannelID try to parse ID
type ChannelProvider ¶
type ChannelProvider interface { Get(id ChannelID) (Channel, error) GetFileDescriptorPressure() int JWTClockSkewLeewayMax() Duration Shutdown(ctx context.Context) }
ChannelProvider provides configured Channel object. If given ChannelID is not valid for this server process, returns (nil, domain.ErrInvalidChannel).
type Duration ¶
Duration wrapper struct
func (Duration) MarshalJSON ¶
MarshalJSON method for configuration marshal/unmarshal
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON method for configuration marshal/unmarshal
type ErrorWithCode ¶
ErrorWithCode is an error interface with error code
func NewErrorWithCode ¶
func NewErrorWithCode(code string) ErrorWithCode
NewErrorWithCode is to make stateless ErrorWithCode instance.
func WrapErrorWithCode ¶
func WrapErrorWithCode(code string, err error) ErrorWithCode
WrapErrorWithCode is to wrap error object with code
type JwtExp ¶
type JwtExp time.Time // Intentionally use time.Time rather than domain.Time to prevent using JSON marshaler of domain.Time
JwtExp is "exp" claim, number of seconds from 1970-01-01T00:00:00Z UTC without leap seconds.
type JwtStorage ¶
type JwtStorage interface { RevokeJwt(ctx context.Context, exp JwtExp, jti JwtJti) error IsRevokedJwt(ctx context.Context, jti JwtJti) (bool, error) }
JwtStorage interface is an abstraction layer of JWT storage implementations
type Message ¶
type Message struct { MessageLocator Content json.RawMessage }
Message is an atomic datagram of the PubSub communication
type MessageID ¶
type MessageID string
MessageID is ID of the message, unique within channel
func ParseMessageID ¶
ParseMessageID try to parse ID
type MessageLocator ¶
MessageLocator is unique identifier of the Message, unique within channel
type PubSubStorage ¶
type PubSubStorage interface { NewSubscriber(ctx context.Context, sl SubscriberLocator) error RemoveSubscriber(ctx context.Context, sl SubscriberLocator) error // All messages must belong to same channel. PublishMessages(ctx context.Context, msgs []Message) error // Storage implementation can return more messages than given max count. // When length of the returned messages is zero, returned AckHandle is not valid thus caller should ignore it. FetchMessages(ctx context.Context, sl SubscriberLocator, max int, waituntil Duration) (messages []Message, moreMessages bool, ackHandle AckHandle, err error) AcknowledgeMessages(ctx context.Context, handle AckHandle) error // If the message had been acknowledged or sent before subscriber creation, returns true. Otherwise false (can includes unsure messages). IsOldMessages(ctx context.Context, sl SubscriberLocator, msgs []MessageLocator) (map[MessageLocator]bool, error) }
PubSubStorage interface is an abstraction layer of PubSub storage implementations
type Regex ¶
type Regex struct {
// contains filtered or unexported fields
}
Regex wrapper struct
func (*Regex) GroupNames ¶
GroupNames returns list of group (subregex) names
func (Regex) MarshalJSON ¶
MarshalJSON method for configuration marshal/unmarshal
func (*Regex) Match ¶
Match against given string and returns map of named groups. If not match returns nil.
func (*Regex) UnmarshalJSON ¶
UnmarshalJSON method for configuration marshal/unmarshal
type Storage ¶
type Storage interface { String() string // Stringer Shutdown(ctx context.Context) error // Liveness probe, returns "encoding/json" encodable value. Liveness(ctx context.Context) (interface{}, error) // Readiness probe, returns "encoding/json" encodable value. Readiness(ctx context.Context) (interface{}, error) // Retruns nil if neither supported nor supported. AsPubSubStorage() PubSubStorage // Retruns nil if neither supported nor supported. AsJwtStorage() JwtStorage // Estimated maximum pressure of syscall.RLIMIT_NOFILE GetFileDescriptorPressure() int }
Storage interface is an abstraction layer of storage implementations
type SubscriberID ¶
type SubscriberID string
SubscriberID is ID of the subscriber, unique within channel
func ParseSubscriberID ¶
func ParseSubscriberID(str string) (SubscriberID, error)
ParseSubscriberID try to parse ID
type SubscriberLocator ¶
type SubscriberLocator struct { ChannelID ChannelID SubscriberID SubscriberID }
SubscriberLocator is unique identifier of the PubSub subscriber, unique within channel
type SystemClock ¶
type SystemClock interface {
Now() Time
}
SystemClock is an interface to get current time Do not use time.Now() directly to make codes testable.
var RealSystemClock SystemClock = &realSystemClock
RealSystemClock is just a time.Now()
type TemplateString ¶
type TemplateString struct {
// contains filtered or unexported fields
}
TemplateString is Template wrappwer struct
func NewTemplateString ¶
func NewTemplateString(value string) (TemplateString, error)
NewTemplateString initialize template
func (TemplateString) Execute ¶
func (tpl TemplateString) Execute(data TemplateStringEnv) (string, error)
Execute evaluates template
func (TemplateString) MarshalJSON ¶
func (tpl TemplateString) MarshalJSON() ([]byte, error)
MarshalJSON method for configuration marshal/unmarshal
func (TemplateString) String ¶
func (tpl TemplateString) String() string
String returns original template string
func (*TemplateString) UnmarshalJSON ¶
func (tpl *TemplateString) UnmarshalJSON(b []byte) error
UnmarshalJSON method for configuration marshal/unmarshal
type TemplateStringEnv ¶
type TemplateStringEnv interface{}
TemplateStringEnv is an parameters for template evaluation
type TemplateStrings ¶
type TemplateStrings struct {
Templates []TemplateString
}
TemplateStrings is list of TemplateString
func NewTemplateStrings ¶
func NewTemplateStrings(templates ...TemplateString) TemplateStrings
NewTemplateStrings initialize templates
func (TemplateStrings) Execute ¶
func (ts TemplateStrings) Execute(data TemplateStringEnv) ([]string, error)
Execute evaluates templates
func (TemplateStrings) MarshalJSON ¶
func (ts TemplateStrings) MarshalJSON() ([]byte, error)
MarshalJSON method for configuration marshal/unmarshal
func (TemplateStrings) String ¶
func (ts TemplateStrings) String() string
String returns original template strings
func (*TemplateStrings) UnmarshalJSON ¶
func (ts *TemplateStrings) UnmarshalJSON(b []byte) error
UnmarshalJSON method for configuration marshal/unmarshal