kchainws

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: MIT Imports: 6 Imported by: 0

README

kchainws 💜

Consume KleverChain node socket messages easyly 🚀

About the project 🌟

  • Connect to your node with this client
  • Read and Handle messages gracefully

Installation ⚙️

go get -u github.com/hyperyuri/kchainws

Quick Start 📚

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilClient       = errors.New("client is nil")
	ErrInvalidURI      = errors.New("URI provided is invalid")
	ErrEmptyDeliveries = errors.New("empty deliveries")
	ErrInvalidType     = errors.New("type provided is invalid")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client ws client

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient creates a new ws client

func (*Client) Close

func (c *Client) Close() error

Close conn and remove readers

func (*Client) Context

func (c *Client) Context() context.Context

Context return the context

func (Client) GetReader

func (c Client) GetReader() Delivery

GetReader return a reader to watch messages

func (*Client) StarConnection

func (c *Client) StarConnection() error

StarConnection create a conn and return messages to readers

type Customization

type Customization struct {
	Addresses []string `json:"addresses"`
	Types     []string `json:"subcribed_types"`
}

Customization is the customization for the ws

func NewCustom

func NewCustom(types []Types, addresses ...string) *Customization

NewCustom creates a customization to your client

type Delivery

type Delivery chan []byte

Delivery is the response from your ws

type Option

type Option func(*Client) error

Option is responsible for the client setup

func WithContext

func WithContext(ctx context.Context) Option

WithContext setup a custom context to the client

func WithCustom

func WithCustom(custom *Customization) Option

WithCustom setup your customization pattern

func WithURL

func WithURL(nodeHost string) Option

WithURL setup the node host to Client

type Types

type Types string

Types you can choose the socket message types to receive

const (
	UNKNOWN Types = "UNKNOWN"
	//USER_TRANSACTIONS read address transactions
	USER_TRANSACTIONS Types = "user_transaction"
	//ACCOUNTS read address account changes
	ACCOUNTS Types = "accounts"
	//TRANSACTIONS read all transactions
	TRANSACTIONS Types = "transaction"
	//BLOCKS read only blocks
	BLOCKS Types = "blocks"
)

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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