shoset

package module
v0.0.0-...-dd333d9 Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: MPL-2.0 Imports: 12 Imported by: 10

README

shoset

A smart multi-ends socket library.

Documentation

Missing. -- Find a usage example in the gandalf project.

Design principles

For now, over to the team's taiga

Running tests

git clone https://github.com/ditrit/shoset
go run test/test.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeltaAddress

func DeltaAddress(addr string, portDelta int) (string, bool)

DeltaAddress return a new address with same host but with a new port (old one with an offset)

func GetCommand

func GetCommand(c *ShosetConn) (msg.Message, error)

GetCommand :

func GetConfig

func GetConfig(c *ShosetConn) (msg.Message, error)

TODO MOVE TO GANDALF GetConfig :

func GetConfigBye

func GetConfigBye(c *ShosetConn) (msg.Message, error)

GetConfigBye :

func GetConfigJoin

func GetConfigJoin(c *ShosetConn) (msg.Message, error)

GetConfigJoin :

func GetConfigLink(c *ShosetConn) (msg.Message, error)

GetConfigLink :

func GetEvent

func GetEvent(c *ShosetConn) (msg.Message, error)

GetEvent :

func GetIP

func GetIP(address string) (string, error)

GetIP :

func HandleCommand

func HandleCommand(c *ShosetConn, message msg.Message) error

HandleCommand :

func HandleConfig

func HandleConfig(c *ShosetConn, message msg.Message) error

HandleConfig :config

func HandleConfigBye

func HandleConfigBye(c *ShosetConn, message msg.Message) error

HandleConfigBye :

func HandleConfigJoin

func HandleConfigJoin(c *ShosetConn, message msg.Message) error

HandleConfigJoin :

func HandleConfigLink(c *ShosetConn, message msg.Message) error

HandleConfigLink :

func HandleEvent

func HandleEvent(c *ShosetConn, message msg.Message) error

HandleEvent :

func IP2ID

func IP2ID(ip string) (uint64, bool)

IP2ID :

func SendCommand

func SendCommand(c *Shoset, cmd msg.Message)

SendCommand :

func SendConfig

func SendConfig(c *Shoset, cmd msg.Message)

SendConfig :

func SendEvent

func SendEvent(c *Shoset, evt msg.Message)

SendEvent :

func SendEventConn

func SendEventConn(c *ShosetConn, evt interface{})

SendEventConn :

func WaitCommand

func WaitCommand(c *Shoset, replies *msg.Iterator, args map[string]string, timeout int) *msg.Message

WaitCommand :

func WaitConfig

func WaitConfig(c *Shoset, replies *msg.Iterator, args map[string]string, timeout int) *msg.Message

WaitConfig :

func WaitEvent

func WaitEvent(c *Shoset, replies *msg.Iterator, args map[string]string, timeout int) *msg.Message

WaitEvent :

Types

type MapSafe

type MapSafe struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MapSafe : simple key map safe for goroutines...

func NewMapSafe

func NewMapSafe() *MapSafe

NewMapSafe : constructor

func (*MapSafe) Delete

func (m *MapSafe) Delete(key string)

Delete : delete a value in a MapSafe

func (*MapSafe) Get

func (m *MapSafe) Get(key string) interface{}

Get : Get a value from a MapSafe

func (*MapSafe) Iterate

func (m *MapSafe) Iterate(iter func(string, interface{}))

Iterate : iterate through MapSafe Values using a function

func (*MapSafe) Len

func (m *MapSafe) Len() int

Len : return length of the map

func (*MapSafe) Set

func (m *MapSafe) Set(key string, value interface{}) *MapSafe

Set : assign a value to a MapSafe

type MapSafeBool

type MapSafeBool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MapSafeBool : simple key map safe for goroutines...

func NewMapSafeBool

func NewMapSafeBool() *MapSafeBool

NewMapSafeBool : constructor

func (*MapSafeBool) Delete

func (m *MapSafeBool) Delete(key string)

Delete : delete a value in a MapSafeBool

func (*MapSafeBool) Get

func (m *MapSafeBool) Get(key string) bool

Get : Get a value from a MapSafeBool

func (*MapSafeBool) Iterate

func (m *MapSafeBool) Iterate(iter func(string, bool))

Iterate : iterate through MapSafeBool Values using a function

func (*MapSafeBool) Len

func (m *MapSafeBool) Len() int

Len : return length of the map

func (*MapSafeBool) Set

func (m *MapSafeBool) Set(key string, value bool) *MapSafeBool

Set : assign a value to a MapSafeBool

type MapSafeConn

type MapSafeConn struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MapSafeConn : simple key map safe for goroutines...

func NewMapSafeConn

func NewMapSafeConn() *MapSafeConn

NewMapSafeConn : constructor

func (*MapSafeConn) Delete

func (m *MapSafeConn) Delete(key string)

Delete : delete a value in a MapSafeConn

func (*MapSafeConn) Get

func (m *MapSafeConn) Get(key string) *ShosetConn

Get : Get a value from a MapSafeConn

func (*MapSafeConn) GetByType

func (m *MapSafeConn) GetByType(shosetType string) []*ShosetConn

Get : Get a value from a MapSafeConn

func (*MapSafeConn) GetM

func (m *MapSafeConn) GetM() map[string]*ShosetConn

Get : Get Map

func (*MapSafeConn) Iterate

func (m *MapSafeConn) Iterate(iter func(string, *ShosetConn))

Iterate : iterate through MapSafeConn Values using a function

func (*MapSafeConn) Keys

func (m *MapSafeConn) Keys(dir string) []string

func (*MapSafeConn) Len

func (m *MapSafeConn) Len() int

Len : return length of the map

func (*MapSafeConn) Set

func (m *MapSafeConn) Set(key string, value *ShosetConn) *MapSafeConn

Set : assign a value to a MapSafeConn

type MapSafeMapConn

type MapSafeMapConn struct {
	sync.Mutex
	ConfigName string
	// contains filtered or unexported fields
}

MapSafeMapConn : simple key map safe for goroutines...

func NewMapSafeMapConn

func NewMapSafeMapConn() *MapSafeMapConn

NewMapSafeMapConn : constructor

func (*MapSafeMapConn) Delete

func (m *MapSafeMapConn) Delete(lname, key string)

Delete : delete a value in a MapSafeMapConn

func (*MapSafeMapConn) Get

func (m *MapSafeMapConn) Get(key string) *MapSafeConn

Get : Get a value from a MapSafeMapConn

func (*MapSafeMapConn) GetConfig

func (m *MapSafeMapConn) GetConfig() ([]string, []string)

func (*MapSafeMapConn) Iterate

func (m *MapSafeMapConn) Iterate(lname string, iter func(string, *ShosetConn))

Iterate : iterate through MapSafeMapConn Values using a function

func (*MapSafeMapConn) IterateAll

func (m *MapSafeMapConn) IterateAll(iter func(string, *ShosetConn))

func (*MapSafeMapConn) Keys

func (m *MapSafeMapConn) Keys() []string

func (*MapSafeMapConn) Len

func (m *MapSafeMapConn) Len() int

Len : return length of the map

func (*MapSafeMapConn) Set

func (m *MapSafeMapConn) Set(lname, key, protocolType, shosetType string, value *ShosetConn) *MapSafeMapConn

Set : assign a value to a MapSafeMapConn

func (*MapSafeMapConn) SetConfigName

func (m *MapSafeMapConn) SetConfigName(name string)

func (*MapSafeMapConn) SetViper

func (m *MapSafeMapConn) SetViper(viperConfig *viper.Viper)

type MapSafeStrings

type MapSafeStrings struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MapSafeStrings : simple key map safe for goroutines...

func NewMapSafeStrings

func NewMapSafeStrings() *MapSafeStrings

NewMapSafeStrings : constructor

func (*MapSafeStrings) Delete

func (m *MapSafeStrings) Delete(key string)

Delete : delete a value in a MapSafeStrings

func (*MapSafeStrings) Get

func (m *MapSafeStrings) Get(key string) map[string]bool

Get : Get a value from a MapSafeStrings

func (*MapSafeStrings) Iterate

func (m *MapSafeStrings) Iterate(iter func(string, map[string]bool))

Iterate : iterate through MapSafeStrings Values using a function

func (*MapSafeStrings) Keys

func (m *MapSafeStrings) Keys(key string) []string

func (*MapSafeStrings) Len

func (m *MapSafeStrings) Len() int

Len : return length of the map

func (*MapSafeStrings) Set

func (m *MapSafeStrings) Set(key, value string)

type MessageHandlers

type MessageHandlers interface {
	Handle(*ShosetConn) error
	SendConn(*ShosetConn, *msg.Message)
	Send(*Shoset, *msg.Message)
	Wait(*Shoset, *msg.Iterator, string, int) *msg.Message
}

MessageHandlers interface

type Shoset

type Shoset struct {
	Context map[string]interface{} //TOTO

	//	id          string
	ConnsByName      *MapSafeMapConn // map[string]map[string]*ShosetConn   connexions par nom logique
	LnamesByType     *MapSafeStrings // for gandalf
	LnamesByProtocol *MapSafeStrings

	ShosetType string // Type logique de la shoset

	// Dictionnaire des queues de message (par type de message)
	Queue  map[string]*msg.Queue
	Get    map[string]func(*ShosetConn) (msg.Message, error)
	Handle map[string]func(*ShosetConn, msg.Message) error
	Send   map[string]func(*Shoset, msg.Message)
	Wait   map[string]func(*Shoset, *msg.Iterator, map[string]string, int) *msg.Message

	// synchronisation des goroutines
	Done chan bool
	// contains filtered or unexported fields
}

Shoset :

func NewShoset

func NewShoset(lName, ShosetType string) *Shoset

Constructor

func (*Shoset) Bind

func (c *Shoset) Bind(address string) error

Bind : Connect to another Shoset

func (Shoset) GetBindAddress

func (c Shoset) GetBindAddress() string

Accessors

func (*Shoset) GetConnsByType

func (c *Shoset) GetConnsByType(shosetType string) map[string]*ShosetConn

func (*Shoset) GetConnsByTypeArray

func (c *Shoset) GetConnsByTypeArray(shosetType string) []*ShosetConn

func (*Shoset) GetIsValid

func (c *Shoset) GetIsValid() bool

func (Shoset) GetLogicalName

func (c Shoset) GetLogicalName() string

func (Shoset) GetShosetType

func (c Shoset) GetShosetType() string

func (*Shoset) Protocol

func (c *Shoset) Protocol(address, protocolType string) (*ShosetConn, error)

func (*Shoset) SetBindAddress

func (c *Shoset) SetBindAddress(bindAddress string)

func (*Shoset) SetIsValid

func (c *Shoset) SetIsValid(state bool)

func (Shoset) String

func (c Shoset) String() string

Display with fmt - override the print of the object

type ShosetConn

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

ShosetConn : client connection

func GetByType

func GetByType(m *MapSafeConn, shosetType string) []*ShosetConn

GetByType : Get shoset by type.

func NewShosetConn

func NewShosetConn(c *Shoset, address string, dir string) (*ShosetConn, error)

func (*ShosetConn) Flush

func (c *ShosetConn) Flush() error

Flush :

func (*ShosetConn) GetCh

func (c *ShosetConn) GetCh() *Shoset

GetCh :

func (*ShosetConn) GetDir

func (c *ShosetConn) GetDir() string

GetDir :

func (*ShosetConn) GetIsValid

func (c *ShosetConn) GetIsValid() bool

func (*ShosetConn) GetLocalAddress

func (c *ShosetConn) GetLocalAddress() string

GetBindAddr : port sur lequel on est bindé

func (*ShosetConn) GetLocalLogicalName

func (c *ShosetConn) GetLocalLogicalName() string

func (*ShosetConn) GetLocalShosetType

func (c *ShosetConn) GetLocalShosetType() string

func (*ShosetConn) GetRemoteAddress

func (c *ShosetConn) GetRemoteAddress() string

func (*ShosetConn) GetRemoteLogicalName

func (c *ShosetConn) GetRemoteLogicalName() string

GetName : // remote logical Name

func (*ShosetConn) GetRemoteShosetType

func (c *ShosetConn) GetRemoteShosetType() string

GetShosetType : // remote ShosetTypeName

func (*ShosetConn) ReadMessage

func (c *ShosetConn) ReadMessage(data interface{}) error

ReadMessage :

func (*ShosetConn) ReadString

func (c *ShosetConn) ReadString() (string, error)

ReadString :

func (*ShosetConn) SendMessage

func (c *ShosetConn) SendMessage(msg msg.Message)

SendMessage :

func (*ShosetConn) SetIsValid

func (c *ShosetConn) SetIsValid(state bool)

func (*ShosetConn) SetLocalAddress

func (c *ShosetConn) SetLocalAddress(bindAddress string)

SetBindAddr :

func (*ShosetConn) SetRemoteAddress

func (c *ShosetConn) SetRemoteAddress(address string)

func (*ShosetConn) SetRemoteLogicalName

func (c *ShosetConn) SetRemoteLogicalName(lName string)

SetName : // remote logical Name

func (*ShosetConn) SetRemoteShosetType

func (c *ShosetConn) SetRemoteShosetType(ShosetType string)

SetShosetType : // remote ShosetType

func (*ShosetConn) String

func (c *ShosetConn) String() string

func (*ShosetConn) WriteMessage

func (c *ShosetConn) WriteMessage(data interface{}) error

WriteMessage :

func (*ShosetConn) WriteString

func (c *ShosetConn) WriteString(data string) (int, error)

WriteString :

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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