service

package
v0.23.3 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package service provides the functionality to interact with a service over a network.

Package service provides the functionality to interact with a service over a network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exchange

type Exchange struct {
	Service string             // The service to which this message is directed.
	Answer  bool               // Indicates if this message expects a response.
	Req     *generated.Request // The transport request associated with this message.
}

Exchange struct represents a service message.

func NewExchange

func NewExchange(service string, answer bool) *Exchange

NewExchange creates a new Exchange instance.

Parameters: - service: The service to which the exchange is directed. - answer: Whether the exchange expects a response or not.

Returns: - exchange: A pointer to the newly created exchange object.

type Service

type Service struct {
	Name      string // The name of the service, usually in URI form.
	Address   string // The address of the server.
	Protocol  string // The network protocol to use (e.g., TCP, UDP).
	ID        string // A unique identifier for this connection.
	Connected bool   // True if a connection has been established, false otherwise.

	Network net.Conn // The underlying network connection.
	// contains filtered or unexported fields
}

Service struct represents a remote service to interact with.

func Create

func Create(address, port string) (*Service, error)

Create initializes a Service instance.

Parameters: - address: The address of the remote service. - port: The port number of the remote service.

Returns: - service: A pointer to a Service instance. - err: An error if any.

func (*Service) Connect

func (s *Service) Connect() error

Connect establishes a connection to the server.

Returns: - err: An error if the connection fails or if already connected.

func (*Service) Disconnect

func (s *Service) Disconnect() error

Disconnect closes the connection.

Returns: - err: An error if the disconnection fails.

func (*Service) MakeExchange

func (s *Service) MakeExchange(answer ...bool) *Exchange

MakeExchange creates a new Exchange instance for this service.

Parameters: - answer: Optional boolean argument to specify if the exchange should be answered.

Returns: - exchange: A pointer to a new Exchange instance.

func (*Service) Write

func (s *Service) Write(data *bytes.Buffer) (int, error)

Write sends data to the service.

Parameters: - data: Buffer containing the data to be sent.

Returns: - n: The number of bytes written. - err: An error if any.

Jump to

Keyboard shortcuts

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