gophoenixsocketclient

package module
v0.0.0-...-9c3cf26 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: MIT Imports: 14 Imported by: 0

README

Go Phoenix Socket Client

CircleCI Go Report Card codecov

GoPhoenixSocketClient is a golang port of phoenix.js

This project should first port phoenix.js (javascript) to golang. Then it should be compliant with golang standards.

Installation

go get github.com/akdilsiz/go-phoenix-socket-client

Examples

..

Documentation

..

Contribution

All contributions are welcomed as long as you follow the conventions of Go language.

LICENSE

GoPhoenixSocketClient is available under the MIT license. See the LICENSE file for more info.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	Grow float64
	// contains filtered or unexported fields
}

Buffer Offset writable memory buffer. Reference by: https://github.com/aws/aws-sdk-go/blob/v1.44.33/aws/types.go#L163-L172

func NewBuffer

func NewBuffer(l int64) *Buffer

NewBuffer make offset writable memory buffer.

func NewBufferFromValues

func NewBufferFromValues(buf []byte) *Buffer

NewBufferFromValues make offset writable memory buffer with defined buf.

func (*Buffer) Bytes

func (buf *Buffer) Bytes() []byte

Bytes returns all bytes in the memory buffer.

func (*Buffer) Length

func (buf *Buffer) Length() int64

Length returns the size of the memory buffer.

func (*Buffer) Reset

func (buf *Buffer) Reset()

Reset clears the memory buffer.

func (*Buffer) WriteAt

func (buf *Buffer) WriteAt(payload []byte, offset int64) (n int, err error)

WriteAt write memory buffer with offset position

type CloseEvent

type CloseEvent struct {
	Code     int
	Reason   string
	WasClean bool
}

CloseEvent ..

type Hook

type Hook struct {
	Status   int
	Callback func(received Received)
}

Hook ..

type Logger

type Logger interface {
	Info(service string, method string, args ...interface{})
	Warn(service string, method string, args ...interface{})
	Debug(service string, method string, args ...interface{})
	Error(service string, method string, args ...interface{})
	Printf(format string, args ...interface{})
	Level(string) Logger
	Format(string) Logger
}

Logger logging system interface

func NewLogger

func NewLogger(ctx context.Context, version string) Logger

NewLogger initialize logging system

type Longpoll

type Longpoll interface {
	EndpointURL() (*url.URL, error)
	SetOnClose(fn func(event CloseEvent))
	SetOnError(fn func(err string))
}

Longpoll phoenix longpoll transport interface

func NewLongpoll

func NewLongpoll(ctx context.Context, endpoint string) Longpoll

NewLongpoll initialize phoenix longpoll connector

type Message

type Message struct {
	JoinRef string                 `json:"join_ref"`
	Ref     string                 `json:"ref"`
	Event   constants.ChannelEvent `json:"event"`
	Topic   string                 `json:"topic"`
	Payload []byte                 `json:"payload"`
}

Message ..

type Push

type Push interface {
	Resend(timeout time.Duration)
	Reset()
	Send()
}

Push ..

func NewPush

func NewPush(channel string,
	event constants.ChannelEvent,
	payload []byte,
	timeout time.Duration) Push

NewPush ..

type Received

type Received struct {
	Status   string
	Response []byte
	Ref      string
}

Received ..

type Serializer

type Serializer interface {
	Encode(message Message, callback func([]byte))
	Decode(rawPayload []byte, callback func([]byte))
}

Serializer ..

func NewSerializer

func NewSerializer() Serializer

NewSerializer initialize default serializer

type Socket

type Socket interface {
	Protocol() string
	EndpointURL() string
	ReplaceTransport(newTransport constants.Transport)
	Disconnect(callback func(), code int, reason string)
	Teardown(callback func(), code int, reason string)
	MakeRef() string
}

Socket phoenix websocket transport interface

func NewSocket

func NewSocket(ctx context.Context, endpoint string, options ...*SocketOptions) Socket

NewSocket initialize phoenix websocket connector

type SocketOptions

type SocketOptions struct {
	Timeout             time.Duration
	Transport           constants.Transport
	Encode              Serializer
	Decode              Serializer
	HeartbeatIntervalMS time.Duration
	RejoinAfterMS       TimerCalc
	ReconnectAfterMS    TimerCalc
	Logger              Logger
	LongpollerTimeout   time.Duration
	Params              url.Values
	VSN                 string
}

SocketOptions phoenix websocket connector options

func DefaultSocketOptions

func DefaultSocketOptions() *SocketOptions

DefaultSocketOptions phoenix websocket default options

type State

type State struct {
	Ref      int64
	Callback func()
}

State ..

type StateChange

type StateChange struct {
	Open    []State
	Close   []State
	Error   []State
	Message []State
}

StateChange ..

type Timer

type Timer interface {
	Tries() int
	Reset()
	ScheduleTimeout()
}

Timer scheduling system

func NewTimer

func NewTimer(ctx context.Context, callback func(), timerCalc TimerCalc) Timer

NewTimer initialize timer

type TimerCalc

type TimerCalc func(tries int) time.Duration

TimerCalc ..

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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