Skip to content

Add notification client library#62

Closed
jpellizzari wants to merge 3 commits intomasterfrom
notifications
Closed

Add notification client library#62
jpellizzari wants to merge 3 commits intomasterfrom
notifications

Conversation

@jpellizzari
Copy link
Contributor

Fixes https://github.com/weaveworks/notification/issues/21

Adds a first iteration of a client library for notifications. This intentionally contains very little abstraction and only be used for an initial non-customer-facing service, such as service-ui-kicker.

}

type event struct {
Type string `json:"type"`

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.


eventBytes, err := json.Marshal(e)
if err != nil {
return errors.Wrapf(err, "Cannot marshal event to []byte %v", msg)

This comment was marked as abuse.

// BrowserMessage contains the required fields for formatting browser notifications
type BrowserMessage struct {
Type string `json:"type"`
Text string `json:"text"`

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.


// SlackMessage contains the required fields for formatting slack messages
type SlackMessage struct {
Text string `json:"text"`

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

},
Slack: notifications.SlackMessage{
Text: markdown,
},

This comment was marked as abuse.

This comment was marked as abuse.


defer resp.Body.Close()

if err != nil {

This comment was marked as abuse.

resp, err := http.DefaultClient.Do(req)
if err != nil {
return errors.Wrap(err, "Failed to POST event")
}

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

}

// SendEvent sends an event to the notification service.
func (s *Sender) SendEvent(et string, instance string, t time.Time, msg *Message) error {

This comment was marked as abuse.

Type string `json:"type"`
InstanceID string `json:"instance_id"`
Timestamp time.Time `json:"timestamp"`
Messages *Message `json:"messages"`

This comment was marked as abuse.


eventBytes, err := json.Marshal(e)
if err != nil {
return errors.Wrapf(err, "Cannot marshal event to []byte %s", err)

This comment was marked as abuse.

@jpellizzari jpellizzari closed this Oct 4, 2017
yeya24 pushed a commit to yeya24/common that referenced this pull request Jun 12, 2024
Migrate ZeroSample and ZeroSamplePair to model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants