connection

package
v0.0.0-...-e438b56 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UUIDList

func UUIDList(input interface{}) error

UUIDList valdiates

Types

type Conn

type Conn interface {
	Authorize() error
	GetConversant() repositories.Conversant
	Requests() chan Request
	Response() chan Response
	Leave() chan struct{}
}

Conn is the generic connection interface that allows multiple connections to talk to each other over any protocol

type CreateConversationRequest

type CreateConversationRequest struct {
	SenderID    string   `json:"-"`
	Name        string   `json:"name"`
	Conversants []string `json:"conversants"`
}

CreateConversationRequest takes in a name and list of extra users to add to the conversation. SenderID is for internal use only, and should not be marshalled

func (CreateConversationRequest) Validate

func (request CreateConversationRequest) Validate() error

type MockConn

type MockConn struct {
	Auth       func() error
	Conversant func() repositories.Conversant
	Request    func() chan Request
	Resp       func() chan Response
	Leaver     func() chan struct{}
}

func (*MockConn) Authorize

func (mock *MockConn) Authorize() error

func (*MockConn) GetConversant

func (mock *MockConn) GetConversant() repositories.Conversant

func (*MockConn) Leave

func (mock *MockConn) Leave() chan struct{}

func (*MockConn) Requests

func (mock *MockConn) Requests() chan Request

func (*MockConn) Response

func (mock *MockConn) Response() chan Response

type NewMessageResponse

type NewMessageResponse struct {
	repositories.Message
}

type Request

type Request struct {
	Type RequestType `json:"type"`
	Data interface{} `json:"data"`
}

Request is a struct with a dynamic body, with a specific type that allows the MUX to figure out how to cast the body

type RequestType

type RequestType int
const (
	SendMessage RequestType = iota
	CreateConversation
	RetrieveConversation
	RequestError
)

type Response

type Response struct {
	Type ResponseType `json:"type"`
	Data interface{}  `json:"data"`
}

func NewResponseError

func NewResponseError(error string) Response

type ResponseError

type ResponseError struct {
	Error string `json:"error"`
}

type ResponseType

type ResponseType int
const (
	Error ResponseType = iota
	NewMessage
	NewConversation
	ReturnConversation
)

type RetrieveConversationRequest

type RetrieveConversationRequest struct {
	ConversationID string `json:"conversationId"`
	Limit          int    `json:"limit"`
	Offset         int    `json:"offset"`
}

RetrieveConversationRequest uses a limit offset pattern in order to return chats from a conversation

func (RetrieveConversationRequest) Validate

func (request RetrieveConversationRequest) Validate() error

type SendMessageRequest

type SendMessageRequest struct {
	SenderID       string `json:"-"`
	Message        string `json:"message"`
	ConversationID string `json:"conversationId"`
}

SendMessageRequest takes the message and conversation ID and sends the given message to the conversation

func (SendMessageRequest) Validate

func (request SendMessageRequest) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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