rest

package
v0.0.0-...-82b0641 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultName    = "stark.http.server"
	DefaultVersion = time.Now().Format("2006.01.02.15.04")
	DefaultId      = uuid.New().String()
	DefaultAddress = ":0"

	DefaultRegisterInterval = time.Second * 30
	DefaultRegisterTTL      = time.Minute
)
View Source
var (
	DefaultTimeout = time.Second * 2
)

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(name string, s selector.Selector, opt ...ClientOption) (*Client, error)

func (*Client) Request

func (c *Client) Request() (*resty.Request, error)

type ClientOption

type ClientOption func(*ClientOptions)

func Scheme

func Scheme(s string) ClientOption

func Timeout

func Timeout(t time.Duration) ClientOption

type ClientOptions

type ClientOptions struct {
	Timeout time.Duration
	Scheme  string
}

type Server

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

func NewSever

func NewSever(rg registry.Registry, handler http.Handler, opts ...ServerOption) *Server

func (*Server) Options

func (s *Server) Options() ServerOptions

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop() error

func (*Server) String

func (s *Server) String() string

type ServerOption

type ServerOption func(o *ServerOptions)

func Address

func Address(a string) ServerOption

Address to bind to - host:port

func Id

func Id(id string) ServerOption

Unique server id

func Metadata

func Metadata(md map[string]string) ServerOption

Metadata associated with the service

func Name

func Name(n string) ServerOption

Server name

func RegisterInterval

func RegisterInterval(t time.Duration) ServerOption

func RegisterTTL

func RegisterTTL(t time.Duration) ServerOption

func TLS

func TLS(certFile, keyFile string) ServerOption

func Version

func Version(v string) ServerOption

Version of the service

type ServerOptions

type ServerOptions struct {
	Name     string
	Version  string
	Id       string
	Metadata map[string]string
	Address  string
	CertFile string
	KeyFile  string

	RegisterTTL      time.Duration
	RegisterInterval time.Duration
}

Directories

Path Synopsis
client

Jump to

Keyboard shortcuts

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