sse

package
v2.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2020 License: MIT Imports: 5 Imported by: 0

README

Perkakas SSE Library

This library helps you to send message to SSE server

How To Send Message

type Donation struct {
    DonationID int64 `json:"donation_id"`
    UserID     int64 `json:"user_id"`
    Amount     int64 `json:"amount"` 
}

donationData := Donation{
    DonationID: 334534,
    UserID:     2463,
    Amount:     50000,
}

sseClient := NewSseClient("your-sse-host", "username", "password")

err := sseClient.SendEvent(context.Background(), "/notification/donation-created", donationData)
if err != nil {
    panic(err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Host       string
	Username   string
	Password   string
	HTTPClient *httpclient.HttpClient
}

Client defines object for SSE instance client

func (*Client) SendEvent

func (s *Client) SendEvent(ctx context.Context, eventPath string, payload interface{}) (err error)

SendEvent will send event request to kitabisa SSE server

type ISseClient

type ISseClient interface {
	SendEvent(ctx context.Context, eventPath string, payload interface{}) (err error)
}

ISseClient defines interface of SSE client

func NewSseClient

func NewSseClient(host, username, password string) ISseClient

NewSseClient initializes new instance of SSE client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL