server

package
v0.0.0-...-cb7ffae Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServiceDisabled = errors.New("service disabled")
)

Functions

func NewHttpHandler

func NewHttpHandler(svc Service, logger log.Logger) http.Handler

Types

type HttpResponse

type HttpResponse struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type LoggingMidware

type LoggingMidware struct {
	Service
	// contains filtered or unexported fields
}

func (*LoggingMidware) GetSegments

func (m *LoggingMidware) GetSegments(ctx context.Context, biztag string, count int) (ids []int64, err error)

func (*LoggingMidware) GetSnowflakes

func (m *LoggingMidware) GetSnowflakes(ctx context.Context, biztag string, count int) (ids []int64, err error)

func (*LoggingMidware) HealthCheck

func (m *LoggingMidware) HealthCheck(ctx context.Context, name string) (status int, err error)

type Midware

type Midware func(svc Service) Service

type Option

type Option func(opts *Options)

func WithAddr

func WithAddr(addr string) Option

func WithLogger

func WithLogger(logger log.Logger) Option

func WithMidwares

func WithMidwares(mdws []Midware) Option

func WithName

func WithName(name string) Option

func WithSegmentRepository

func WithSegmentRepository(repo segment.Repository) Option

func WithSnowflakeStorage

func WithSnowflakeStorage(stor snowflake.Storage) Option

type Options

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

type Server

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

func New

func New(svc Service, logger log.Logger) (*Server, error)

func (*Server) Close

func (s *Server) Close() (err error)

func (*Server) Closed

func (s *Server) Closed() bool

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string) error

type Service

type Service interface {
	GetSegments(ctx context.Context, biztag string, count int) (ids []int64, err error)
	GetSnowflakes(ctx context.Context, biztag string, count int) (ids []int64, err error)
	HealthCheck(ctx context.Context, name string) (status int, err error)
	Close() error
}

func Logging

func Logging(logger log.Logger, svc Service) Service

func NewService

func NewService(opts ...Option) Service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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