Skip to content

v2.3.0 Aluminium Kangaroo

Latest
Compare
Choose a tag to compare
@petomalina petomalina released this 30 Jan 21:15

This release adds some exported methods to the existing server and exports the structure. No breaking changes are made since the server is just made public.

The server.Server now exports server.IP(), server.Host(), and server.Port().

Two constants were also added to the server package:

const (
	// RandomPort is a constant used to let the system decide on the port
	// for the server. This is commonly used for services that connect to
	// each other via a registry (the server registers itself with host+port
	// in a central list, so multiple can run on a single machine)
	RandomPort = "0"

	// DefaultTimeout represent a default value for the timeout option of the Server
	DefaultTimeout = time.Second * 30
)

The server.New(server.RandomPort, server.DefaultTimeout) will now return a new *Server struct that exports all necessary information if you need the Host/Port information (e.g. to register the server in some registry).

srv, err := server.New(server.RandomPort, server.DefaultTimeout)
// handle err

// get the random port that was assigned to the server
port := srv.Port()