Documentation
¶
Overview ¶
Server package contains the server implementation for the Teonet proxy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIClients ¶
APIClients stores a map of APIClient instances, keyed by peer name. It uses a RWMutex for concurrent access control.
func (*APIClients) Add ¶
func (cli *APIClients) Add(name string, api *teonet.APIClient)
Add adds a new APIClient instance to the APIClients map, keyed by the provided name. It locks the map during the update to prevent concurrent map writes. It first checks if a client already exists for the given name and returns immediately if so to avoid overwriting the existing client.
func (*APIClients) Exists ¶
func (cli *APIClients) Exists(name string) bool
Exists checks if an APIClient with the given name exists in the APIClients map. It calls the Get method and checks if it returned a client.
func (*APIClients) Get ¶
func (cli *APIClients) Get(name string) (api *teonet.APIClient, ok bool)
Get retrieves the APIClient instance for the given name from the APIClients map. It locks the map for reading during the lookup to prevent concurrent map access. The second return value indicates if a client was found. This is an exported method that is part of the APIClients API.
func (*APIClients) Remove ¶
func (cli *APIClients) Remove(name string)
Remove removes the APIClient instance for the given name from the APIClients map. It locks the map during the update to prevent concurrent map writes.
type TeonetMonitor ¶
type TeonetMonitor struct {
Addr string
AppName string
AppShort string
AppVersion string
TeoVersion string
AppStartTime time.Time
}
TeonetMonitor contains monitoring information to send to the Teonet monitor.
type TeonetServer ¶
type TeonetServer struct {
*sync.Mutex
*ws.WsServer
*teonet.Teonet
// contains filtered or unexported fields
}
TeonetServer is the main server type that contains the core components. It has mutexes for synchronization, the websocket server, the Teonet client, and API clients. As an exported type, it is part of the public API.
func New ¶
func New(appShort string, monitor *TeonetMonitor) (teo *TeonetServer, err error)
New creates a new TeonetServer instance. It initializes the mutex, API clients, Teonet client, and websocket server. The appShort parameter specifies the application name. The monitor parameter optionally configures connecting to a Teonet monitor for metrics reporting. It returns the TeonetServer instance and any error. As an exported function, this serves as the main constructor for the TeonetServer type.