Documentation
¶
Index ¶
- Constants
- func NewHandler(rh *Resthook) http.Handler
- type Config
- type Handler
- type Notification
- type Resthook
- func (rh Resthook) Close()
- func (rh Resthook) DeleteById(id int, r *http.Request) error
- func (rh Resthook) FindById(id int) (*Subscription, error)
- func (rh Resthook) GetResults() <-chan *Notification
- func (rh Resthook) Handler() http.Handler
- func (rh Resthook) Notify(userId int, event string, data interface{}) error
- func (rh Resthook) Save(s *Subscription, r *http.Request) error
- type ResthookStore
- type Status
- type Subscription
Constants ¶
View Source
const ( // start retrying after 5 seconds and // grow exponentially after that: // 1st retry = after 5 seconds // 2nd retry = 5*3 = after 15 seconds // 3rd retry (final) = 5*3*3 = after 45 seconds DefaultInitialRetry int = 5 DefaultRetryMultiplier int = 3 // maximum number of attempts DefaultMaxRetry int = 3 )
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) Unsubscribe ¶
func (h *Handler) Unsubscribe(w http.ResponseWriter, r *http.Request)
type Notification ¶
type Notification struct { Subscription *Subscription Data []byte Status Status Retries int }
type Resthook ¶
type Resthook struct {
// contains filtered or unexported fields
}
func NewResthook ¶
func NewResthook(store ResthookStore, config ...Config) Resthook
func (Resthook) GetResults ¶
func (rh Resthook) GetResults() <-chan *Notification
type ResthookStore ¶
type ResthookStore interface { // Creates subscription if it doesn't have id // and populates the id, otherwise updates it. Save(*Subscription, *http.Request) error FindById(int) (*Subscription, error) FindByUserId(int, string) (*Subscription, error) DeleteById(int, *http.Request) error }
ResthookStore defines APIs for subscription's CRUD operations. Using this you can customise where and how data is actually being stored. Or that you actually use soft-delete to preserve history of subscription.
Click to show internal directories.
Click to hide internal directories.