server

package
v0.0.0-...-73638bf Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2018 License: MIT Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ExitCodeOK = 0

	// Specific error codes. begin 10-
	ExitCodeError = 10 + iota
	ExitCodeParseError
	ExitCodeInvalidArgsError
	ExitCodeSetupServerError
)

Exit codes. used only in Run()

Variables

View Source
var (
	// ErrParseFailed is failed to cli args parse
	ErrParseFailed = errors.New("failed to parse args")
)

Functions

func Error

func Error(w http.ResponseWriter, code int, err error, msg string)

Error is wrapped Respond when error response

func JSON

func JSON(w http.ResponseWriter, code int, src interface{})

JSON is wrapped Respond when success response

func PrintDebugf

func PrintDebugf(format string, args ...interface{})

PrintDebugf behaves like log.Printf only in the debug env

func Respond

func Respond(w http.ResponseWriter, code int, src interface{})

Respond is response write to ResponseWriter

func Routes

func Routes() *router.Router

Routes returns initialized for the topic and subscription router

Types

type CLI

type CLI struct {
	OutStream io.Writer
	ErrStream io.Writer
}

CLI is the command line interface object

func (*CLI) Run

func (c *CLI) Run(args []string) int

Run invokes the CLI with the given arguments

type Config

type Config struct {
	Datastore *datastore.Config `yaml:"datastore"`
}

Config represent yaml config

func LoadConfigFromFile

func LoadConfigFromFile(path string) (*Config, error)

LoadConfigFromFile read config file and create config object

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"reason"`
	Error   error  `json:"-"`
}

ErrorResponse is Error response template

func (*ErrorResponse) String

func (e *ErrorResponse) String() string

type Monitoring

type Monitoring struct{}

Monitoring is monitoring frontend server

func (*Monitoring) SubscriptionDetail

func (m *Monitoring) SubscriptionDetail(w http.ResponseWriter, r *http.Request, id string)

SubscriptionDetail returns detail from subscription stats

func (*Monitoring) SubscriptionSummary

func (m *Monitoring) SubscriptionSummary(w http.ResponseWriter, r *http.Request)

SubscriptionSummary returns summary from subscription stats

func (*Monitoring) Summary

func (m *Monitoring) Summary(w http.ResponseWriter, r *http.Request)

Summary returns summary from all stats

func (*Monitoring) TopicDetail

func (m *Monitoring) TopicDetail(w http.ResponseWriter, r *http.Request, id string)

TopicDetail returns detail from topic stats

func (*Monitoring) TopicSummary

func (m *Monitoring) TopicSummary(w http.ResponseWriter, r *http.Request)

TopicSummary returns summary from topic stats

type PublishData

type PublishData struct {
	Data []byte            `json:"data"`
	Attr map[string]string `json:"attributes"`
}

PublishData represent post publish data

type PublishDatas

type PublishDatas struct {
	Messages []PublishData `json:"messages"`
}

PublishDatas represent PublishData group

type PushConfig

type PushConfig struct {
	Endpoint string            `json:"endpoint"`
	Attr     map[string]string `json:"attributes"`
}

PushConfig represent parmeter of push message

type RequestAck

type RequestAck struct {
	AckIDs []string `json:"ack_ids"`
}

RequestAck represent request ack API json

type RequestModifyAck

type RequestModifyAck struct {
	AckIDs             []string `json:"ack_ids"`
	AckDeadlineSeconds int64    `json:"ack_deadline_seconds"`
}

RequestModifyAck represent request ModifyAck API json

type RequestModifyPush

type RequestModifyPush struct {
	PushConfig *PushConfig `json:"push_config"`
}

RequestModifyPush represent request ModifyPush API json

type RequestPull

type RequestPull struct {
	// TODO: ReturnImmediately bool
	MaxMessages int `json:"max_messages"`
}

RequestPull is represents request json for Pull

type ResourceSubscription

type ResourceSubscription struct {
	Name       string     `json:"name"`
	Topic      string     `json:"topic"`
	Push       PushConfig `json:"push_config"`
	AckTimeout int64      `json:"ack_deadline_seconds"`
}

ResourceSubscription represent create subscription request and response data

type ResponseListSubscription

type ResponseListSubscription struct {
	SubscriptionNames []string `json:"subscriptions"`
}

ResponseListSubscription represent response json of ListSubscription

type ResponsePublish

type ResponsePublish struct {
	MessageIDs []string `json:"message_ids"`
}

ResponsePublish represent reponse publish api

type ResponsePull

type ResponsePull struct {
	Messages []*models.PullMessage `json:"receive_messages"`
}

ResponsePull is represents response json for Pull

type Server

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

Server is topic and subscription frontend server

func NewServer

func NewServer(path string) (*Server, error)

NewServer return initialized server

func (*Server) InitDatastore

func (s *Server) InitDatastore() error

InitDatastore prepare datastore initialize

func (*Server) PrepareServer

func (s *Server) PrepareServer() error

PrepareServer settings datastore and stats configuration

func (*Server) Run

func (s *Server) Run(port int) error

Run start server

type SubscriptionServer

type SubscriptionServer struct{}

SubscriptionServer is subscription frontend server

func (*SubscriptionServer) Ack

Ack is setting ack state

func (*SubscriptionServer) Create

Create is create subscription

func (*SubscriptionServer) Delete

Delete is delete subscription

func (*SubscriptionServer) Get

Get is get already exist subscription

func (*SubscriptionServer) List

List is gets subscription list

func (*SubscriptionServer) ModifyAck

func (s *SubscriptionServer) ModifyAck(w http.ResponseWriter, r *http.Request, id string)

ModifyAck is ack timeout setting already delivered message

func (*SubscriptionServer) ModifyPush

func (s *SubscriptionServer) ModifyPush(w http.ResponseWriter, r *http.Request, id string)

ModifyPush is modify push parameters

func (*SubscriptionServer) Pull

Pull is get some messages

type TopicServer

type TopicServer struct{}

TopicServer is topic frontend server

func (*TopicServer) Create

func (s *TopicServer) Create(w http.ResponseWriter, r *http.Request, id string)

Create is create topic

func (*TopicServer) Delete

func (s *TopicServer) Delete(w http.ResponseWriter, r *http.Request, id string)

Delete is delete topic

func (*TopicServer) Get

func (s *TopicServer) Get(w http.ResponseWriter, r *http.Request, id string)

Get is get already exist topic

func (*TopicServer) List

func (s *TopicServer) List(w http.ResponseWriter, r *http.Request)

List is gets topic list

func (*TopicServer) ListSubscription

func (s *TopicServer) ListSubscription(w http.ResponseWriter, r *http.Request, id string)

ListSubscription is gets topic depends subscription list

func (*TopicServer) Publish

func (s *TopicServer) Publish(w http.ResponseWriter, r *http.Request, id string)

Publish is publish message

Jump to

Keyboard shortcuts

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