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 ¶
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 ¶
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 ¶
Connect establishes a connection to the server.
Returns: - err: An error if the connection fails or if already connected.
func (*Service) Disconnect ¶
Disconnect closes the connection.
Returns: - err: An error if the disconnection fails.
func (*Service) MakeExchange ¶
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.