titan

package module
v1.0.69 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: Apache-2.0 Imports: 39 Imported by: 14

README

Titan

Build Status

Titan is an RPC framework like gRPC, but it uses NATS as transport layer.

It can use in combination with goff to generate a Go client and server from the same .proto file that you'd use to generate gRPC clients and servers. The server is generated as a NATS MsgHandler.

The key features?

  • Lightweight: NATS is small less than ~10MB
  • Service Discovery: Built-in by NATS subject.
  • Load Balancing: Built-in by NATS subject and queue group.
  • High performant: NATS can handle millions of requests per second.
  • Scalability: NATS clustering
  • Request & Reply:
  • Publish & Subscribe:
  • Tracing: Integrated with Jaeger (under construction).
  • Monitoring: NATS monitoring dashboard.
  • Payload validation: https://github.com/go-playground/validator
  • Serialization: Using json
  • Metadata: contextual data is transfer across services.
  • Authentication: Role base checking.

Documentation

Index

Constants

View Source
const (
	NatsServers     = "Nats.Servers"
	NatsReadTimeout = "Nats.ReadTimeout"

	// see https://docs.nats.io/developing-with-nats/connecting/pingpong
	NatsPingInterval        = "Nats.PingInterval"
	NatsMaxPingsOutstanding = "Nats.MaxPingsOutstanding"

	//see https://docs.nats.io/developing-with-nats/events/slow
	NatsPendingLimitByte = "Nats.PendingLimitByte"
	NatsPendingLimitMsg  = "Nats.PendingLimitMsg"

	LoggingFormat  = "Logging.Format"
	LoggingLevel   = "Logging.Level"
	LoggingNoColor = "Logging.NoColor"
)
View Source
const (
	HEALTH_CHECK       = "health_check"
	HEALTH_CHECK_REPLY = "health_check_reply"
	UP                 = "UP"
)
View Source
const (
	MONITORING_CHECK       = "monitoring_check"
	MONITORING_CHECK_REPLY = "monitoring_check_reply"
)
View Source
const (
	XRequestId         = "X-Request-Id"
	XRequestTimeOffset = "X-REQUEST-TIME-OFFSET"
	XLoggerId          = "X-LOGGER-ID"
	XPathParams        = "X-PATH-PARAMS"
	XQueryParams       = "X-QUERY-PARAMS"
	XRequest           = "X-REQUEST"
	XUserInfo          = "X-Silentium-User"
	XGlobalCache       = "X-Global-Cache"
	UberTraceID        = "Uber-Trace-Id"

	XRequestTime    = "X-Request-Time"
	XResponseTime   = "X-Response-Time"
	XOrigin         = "X-Origin"
	XResponseHeader = "X-Response-Header"
)

Variables

This section is empty.

Functions

func AbsPathify

func AbsPathify(inPath string) string

func AddSlashPrefixIfMissing

func AddSlashPrefixIfMissing(path string) string

func BeginRequest added in v1.0.51

func BeginRequest(logger logur.Logger, request RequestInterface)

func EndRequest added in v1.0.51

func EndRequest(logger logur.Logger, response ResponseInterface)

func ExtractLoggablePartsFromUrl

func ExtractLoggablePartsFromUrl(url string) string

func GetLogConfig

func GetLogConfig() *log.Config

func GetLogger

func GetLogger() logur.Logger

func MsgCountLoad added in v1.0.51

func MsgCountLoad() uint64

func MsgErrNumAdd added in v1.0.54

func MsgErrNumAdd(v uint64)

func MsgInNumAdd added in v1.0.54

func MsgInNumAdd(v uint64)

func MsgOutNumAdd added in v1.0.54

func MsgOutNumAdd(v uint64)

func NatsRequestToHttpRequest

func NatsRequestToHttpRequest(rq *Request) (*http.Request, error)

func NewMiddleware

func NewMiddleware(name string, subject string, logger logur.Logger) func(next http.Handler) http.Handler

func RandomString

func RandomString(n int) string

func ReadCookies

func ReadCookies(h http.Header, filter string) []*http.Cookie

func SubjectToUrl

func SubjectToUrl(subject, topic string) string

func UnwrapErr

func UnwrapErr(err error) error

func Url2Subject

func Url2Subject(url string) string

Types

type AppInfo

type AppInfo struct {
	Build BuildInfo `json:"build"`
}

type AuthFunc

type AuthFunc func(*Context) bool

func DenyAll

func DenyAll() AuthFunc

no security roles are allowed.

func IsAnonymous

func IsAnonymous() AuthFunc

func IsAuthenticated

func IsAuthenticated() AuthFunc

func Secured

func Secured(roles ...Role) AuthFunc

type BodyProvider

type BodyProvider interface {
	// ContentType returns the Content-Type of the body.
	ContentType() string
	// Body returns the io.Reader body.
	Body() ([]byte, error)
}

BodyProvider provides Body content for http.Request attachment.

type BuildInfo

type BuildInfo struct {
	Version string `json:"version"`
	Date    string `json:"date"`
	Tag     string `json:"tag"`
}

type Client

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

func GetDefaultClient

func GetDefaultClient() *Client

func NewClient

func NewClient(conn IConnection) *Client

func (*Client) Publish

func (srv *Client) Publish(ctx *Context, subject string, body interface{}) error

func (*Client) SendAndReceiveJson

func (srv *Client) SendAndReceiveJson(ctx *Context, rq *Request, receive interface{}) error

func (*Client) SendRequest

func (srv *Client) SendRequest(ctx *Context, rq *Request) (*Response, error)

func (*Client) Subscribe added in v1.0.48

func (srv *Client) Subscribe(subject string, cb Handler) (ISubscription, error)

type ClientResponseError

type ClientResponseError struct {
	Message  string
	Response *Response
	Cause    error
}

---------------------------------------------------------------------------------------------- mapped from HttpClientResponseException.java Error when invoke another microservices

func (*ClientResponseError) Error

func (h *ClientResponseError) Error() string

func (*ClientResponseError) GetMessage

func (h *ClientResponseError) GetMessage() string

type CommonException

type CommonException struct {
	Status           int // http status
	Message          string
	ServerError      string
	ServerErrorParam interface{}
}

----------- copy from old micronaut infrastructure.exception see CommonException.java todo: really really want to change it from Exception to Error. Go does not use Exception. Will change it soon

func NewCommonException

func NewCommonException(serverError string, param ...interface{}) *CommonException

func (*CommonException) Error

func (e *CommonException) Error() string

func (*CommonException) GetServerError

func (c *CommonException) GetServerError() string

func (*CommonException) GetServerErrorParam

func (c *CommonException) GetServerErrorParam() interface{}

type Connection

type Connection struct {
	Conn *nats.EncodedConn
}

func GetDefaultServer added in v1.0.50

func GetDefaultServer(config *NatsConfig, logger logur.Logger, subject string) (*Connection, error)

func NewConnection

func NewConnection(url string, options ...nats.Option) (*Connection, error)

Connect will attempt to connect to the NATS system. The url can contain username/password semantics. e.g. nats://derek:pass@localhost:4222 Comma separated arrays are also supported, e.g. urlA, urlB. Options start with the defaults but can be overridden.

func (*Connection) Close

func (c *Connection) Close()

func (*Connection) Drain

func (c *Connection) Drain()

func (*Connection) Flush

func (c *Connection) Flush() error

func (*Connection) Publish

func (c *Connection) Publish(subject string, v interface{}) error

func (*Connection) SendRequest

func (c *Connection) SendRequest(rq *Request, subject string) (*Response, error)

func (*Connection) Subscribe added in v1.0.48

func (c *Connection) Subscribe(subject string, cb Handler) (ISubscription, error)

type Context

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

func NewBackgroundContext

func NewBackgroundContext() *Context

func NewContext

func NewContext(c context.Context) *Context

func (*Context) AddResponseHeader added in v1.0.66

func (c *Context) AddResponseHeader(key, value string)

grpc mimic

func (*Context) Deadline

func (c *Context) Deadline() (deadline time.Time, ok bool)

func (*Context) Done

func (c *Context) Done() <-chan struct{}

func (*Context) Err

func (c *Context) Err() error

func (*Context) GetPathParam

func (c *Context) GetPathParam(name string) string

func (*Context) GetResponseHeader added in v1.0.67

func (c *Context) GetResponseHeader() http.Header

func (*Context) GlobalCache

func (c *Context) GlobalCache() *GlobalCache

func (*Context) Logger

func (c *Context) Logger() logur.Logger

func (*Context) LoginToCareProviderAsRoleMustBeUsedAfterAuthentication

func (c *Context) LoginToCareProviderAsRoleMustBeUsedAfterAuthentication(careProviderId string, role Role) *Context

dangerously! only use this function after authentication

func (*Context) Origin added in v1.0.57

func (c *Context) Origin() string

func (*Context) PathParams

func (c *Context) PathParams() PathParams

func (*Context) QueryParams

func (c *Context) QueryParams() QueryParams

func (*Context) Request

func (c *Context) Request() *Request

func (*Context) RequestId

func (c *Context) RequestId() string

func (*Context) RequestTimeZone added in v1.0.62

func (c *Context) RequestTimeZone() *time.Location

func (*Context) SetResponseHeader added in v1.0.66

func (c *Context) SetResponseHeader(key, value string)

func (*Context) UberTraceID added in v1.0.51

func (c *Context) UberTraceID() string

func (*Context) UserInfo

func (c *Context) UserInfo() *UserInfo

func (*Context) UserInfoJson

func (c *Context) UserInfoJson() string

func (*Context) Value

func (c *Context) Value(key interface{}) interface{}

func (*Context) WithValue

func (c *Context) WithValue(key, val interface{}) *Context

type CustomResponseWriter

type CustomResponseWriter struct {
	StatusCode int
	// contains filtered or unexported fields
}

func NewCustomResponseWriter

func NewCustomResponseWriter(w http.ResponseWriter) *CustomResponseWriter

func (*CustomResponseWriter) Header

func (c *CustomResponseWriter) Header() http.Header

func (*CustomResponseWriter) Write

func (c *CustomResponseWriter) Write(b []byte) (int, error)

func (*CustomResponseWriter) WriteHeader

func (c *CustomResponseWriter) WriteHeader(statusCode int)

type DefaultHandlers

type DefaultHandlers struct {
	Subject string
}

func (*DefaultHandlers) AppInfo

func (h *DefaultHandlers) AppInfo(ctx *Context) (*AppInfo, error)

see BuildInfoSource.java

func (*DefaultHandlers) DoHealthCheck added in v1.0.48

func (h *DefaultHandlers) DoHealthCheck() Health

func (*DefaultHandlers) Health

func (h *DefaultHandlers) Health(ctx *Context) (*Health, error)

func (*DefaultHandlers) Register

func (h *DefaultHandlers) Register(r Router)

func (*DefaultHandlers) Subscribe

func (h *DefaultHandlers) Subscribe(s *MessageSubscriber)

type DefaultJsonError

type DefaultJsonError struct {
	Message  string                   `json:"message"`
	LogRef   string                   `json:"logref"`
	Path     string                   `json:"path"`
	Links    map[string][]string      `json:"_links"`
	Embedded map[string][]interface{} `json:"_embedded"`

	TraceId          string            `json:"traceId"`
	ValidationErrors []ValidationError `json:"validationErrors"`
	ServerError      string            `json:"serverError"`
	ServerErrorParam interface{}       `json:"serverErrorParam"` // to support parameter message like "Beim Transformieren des Types {0} in den Type {1} ist ein Fehler aufgetreten."
}

*

  • A class that can be used to represent JSON errors that complies to Vnd.Error without the content type requirements.
  • see RFC 2119.

make it compatible old micronaut code, it's a subject to change latter see HttpClientResponseExceptionHandler.java

type ErrorMessage

type ErrorMessage struct {
	Key   string      `json:"key"`
	Param interface{} `json:"param"`
}

func (*ErrorMessage) String

func (e *ErrorMessage) String() string

type GlobalCache

type GlobalCache struct {
	Data map[string]interface{}
}

type Handler

type Handler interface{}

type HandlerFunc

type HandlerFunc func(*Context, *Request) *Response

type Health

type Health struct {
	Status   string `json:"status"`
	HostName string `json:"hostName"`
	Subject  string `json:"subject"`
	Language string `json:"language"`
}

func HealthCheck

func HealthCheck(ctx *Context, subject string) (*Health, error)

type IConnection

type IConnection interface {
	Publish(subject string, v interface{}) error
	SendRequest(rq *Request, subject string) (*Response, error)
	Flush() error
	Close()
	Drain()
	Subscribe(subject string, cb Handler) (ISubscription, error)
}

type IServer

type IServer interface {
	Stop()
	Start(started ...chan interface{})
}

will change this to ServerInterface to make it consistency

type ISubscription added in v1.0.48

type ISubscription interface {
	Unsubscribe() error
	Drain() error
	SetPendingLimits(msgLimit, bytesLimit int) error
}

type Message

type Message struct {
	Headers http.Header `json:"headers"`
	Body    []byte      `json:"body"`
}

func (*Message) Parse

func (r *Message) Parse(v interface{}) (*Context, error)

type MessageHandler

type MessageHandler func(*Message) error

type MessageSubscriber

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

func NewMessageSubscriber

func NewMessageSubscriber(logger logur.Logger) *MessageSubscriber

func (*MessageSubscriber) Register

func (s *MessageSubscriber) Register(subject string, queue string, handler MessageHandler)

type Middleware

type Middleware struct {
}

type Monitoring added in v1.0.46

type Monitoring struct {
	Status       string `json:"status"`
	HostName     string `json:"hostName"`
	Subject      string `json:"subject"`
	Alloc        uint64 `json:"alloc"`        // currently allocated number of bytes on the heap
	TotalAlloc   uint64 `json:"totalAlloc"`   //cumulative max bytes allocated on the heap (will not decrease),
	Sys          uint64 `json:"sys"`          //total memory obtained from the OS
	Mallocs      uint64 `json:"mallocs"`      //number of allocations
	Frees        uint64 `json:"frees"`        //number  deallocations
	LiveObjects  uint64 `json:"liveObjects"`  //live objects (mallocs - frees)
	PauseTotalNs uint64 `json:"pauseTotalNs"` //total GC pauses since the app has started,
	NumGC        uint32 `json:"numGC"`        // number of completed GC cycles

	NumGoroutine int `json:"numGoroutine"`

	Pid int     `json:"pid"` // process id
	Cpu float64 `json:"cpu"` // cpu usage

	MsgInNum  uint64 `json:"msgInNum"`  // number of  in  messages
	MsgOutNum uint64 `json:"msgOutNum"` // number of  out  messages
	MsgErrNum uint64 `json:"msgErrNum"` // total of errors

	MsgPendingNum int `json:"msgPendingNum"` //pending message in queue

	Language    string `json:"language"`
	RequestTime int64  `json:"requestTime"`
}

func DoMonitoringCheck added in v1.0.48

func DoMonitoringCheck(subject string, m *Message) Monitoring

type Mux

type Mux struct {
	Router chi.Router
}

func NewRouter

func NewRouter(r chi.Router) *Mux

func (*Mux) Register

func (m *Mux) Register(method, path string, handlerFunc HandlerFunc, auths ...AuthFunc)

func (*Mux) RegisterJson

func (m *Mux) RegisterJson(method, path string, h Handler, auths ...AuthFunc)

func (*Mux) RegisterTopic

func (m *Mux) RegisterTopic(topic string, h Handler, auths ...AuthFunc)

func (*Mux) ServeHTTP

func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)

implement http.Handler

func (*Mux) Use added in v1.0.68

func (m *Mux) Use(middlewares ...func(http.Handler) http.Handler)

type NatsConfig

type NatsConfig struct {
	Servers             string
	ReadTimeout         int
	PingInterval        int
	MaxPingsOutstanding int
	PendingLimitMsg     int
	PendingLimitByte    int
}

func GetNatsConfig

func GetNatsConfig() *NatsConfig

func (NatsConfig) GetReadTimeoutDuration

func (c NatsConfig) GetReadTimeoutDuration() time.Duration

type Option

type Option func(*Options) error

Option is a function on the options for a connection.

func Config

func Config(config *NatsConfig) Option

func Logger

func Logger(logger logur.Logger) Option

func Middlewares added in v1.0.68

func Middlewares(middlewares chi.Middlewares) Option

func Queue

func Queue(queue string) Option

func Routes

func Routes(r func(Router)) Option

func Subscribe

func Subscribe(r func(*MessageSubscriber)) Option

type Options

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

Options can be used to create a customized connection.

type PathParams

type PathParams map[string]string

func ParsePathParams

func ParsePathParams(ctx context.Context) PathParams

type Process added in v1.0.46

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

func GetCpuUsage added in v1.0.46

func GetCpuUsage() (*Process, error)

type QueryParams

type QueryParams map[string][]string

type RecordDeleteFailedException

type RecordDeleteFailedException struct {
	*CommonException
}

RecordDeleteFailedException.java

func NewRecordDeleteFailedException

func NewRecordDeleteFailedException(entityType string, id UUID, serverError string) *RecordDeleteFailedException

type RecordNotFoundException

type RecordNotFoundException struct {
	*CommonException
}

RecordNotFoundException.java

func NewRecordNotFoundException

func NewRecordNotFoundException(entityType, id, serverError string) *RecordNotFoundException

type Registration

type Registration struct {
	Subject string
	Queue   string
	Handler MessageHandler
}

type Request

type Request struct {
	Method  string      `json:"method"`
	Headers http.Header `json:"headers"`
	Body    []byte      `json:"body"`
	URL     string      `json:"url"`

	// in case of using NATS subject instead of Restful url prefix
	Subject string `json:"subject"`
}

Request is a simple struct

func HttpRequestToNatsRequest

func HttpRequestToNatsRequest(r *http.Request) (*Request, error)

func (*Request) AddCookie

func (r *Request) AddCookie(c *http.Cookie)

AddCookie adds a cookie to the request. Per RFC 6265 section 5.4, AddCookie does not attach more than one Cookie header field. That means all cookies, if any, are written into the same line, separated by semicolon.

func (*Request) BodyJson

func (r *Request) BodyJson(v interface{}) error

func (*Request) Cookie

func (r *Request) Cookie(name string) (*http.Cookie, error)

Cookie returns the named cookie provided in the request or ErrNoCookie if not found. If multiple cookies match the given name, only one cookie will be returned.

func (*Request) GetHeaders added in v1.0.54

func (r *Request) GetHeaders() http.Header

func (*Request) GetUrl added in v1.0.54

func (r *Request) GetUrl() string

func (*Request) HasBody

func (r *Request) HasBody() bool

type RequestBuilder

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

Request is a simple struct

func NewReqBuilder

func NewReqBuilder() *RequestBuilder

New returns a new default Request.

func (*RequestBuilder) AddHeader

func (r *RequestBuilder) AddHeader(key, value string) *RequestBuilder

Add adds the key, value pair in Headers, appending values for existing keys to the key's values. Header keys are canonicalized.

func (*RequestBuilder) AddHeaders

func (r *RequestBuilder) AddHeaders(header http.Header) *RequestBuilder

func (*RequestBuilder) Body

func (r *RequestBuilder) Body(body []byte) *RequestBuilder

func (*RequestBuilder) BodyJSON

func (r *RequestBuilder) BodyJSON(bodyJSON interface{}) *RequestBuilder

func (*RequestBuilder) BodyProvider

func (r *RequestBuilder) BodyProvider(body BodyProvider) *RequestBuilder

BodyProvider sets the RequestBuilder's body provider.

func (*RequestBuilder) Build

func (r *RequestBuilder) Build() (*Request, error)

func (*RequestBuilder) Connect

func (r *RequestBuilder) Connect(pathURL string) *RequestBuilder

Connect sets the Request method to CONNECT and sets the given pathURL.

func (*RequestBuilder) Delete

func (r *RequestBuilder) Delete(pathURL string) *RequestBuilder

Delete sets the Request method to DELETE and sets the given pathURL.

func (*RequestBuilder) Get

func (r *RequestBuilder) Get(pathURL string) *RequestBuilder

Get sets the Request method to GET and sets the given pathURL.

func (*RequestBuilder) Head

func (r *RequestBuilder) Head(pathURL string) *RequestBuilder

Head sets the Request method to HEAD and sets the given pathURL.

func (*RequestBuilder) Options

func (r *RequestBuilder) Options(pathURL string) *RequestBuilder

Options sets the Request method to OPTIONS and sets the given pathURL.

func (*RequestBuilder) Patch

func (r *RequestBuilder) Patch(pathURL string) *RequestBuilder

Patch sets the Request method to PATCH and sets the given pathURL.

func (*RequestBuilder) Post

func (r *RequestBuilder) Post(pathURL string) *RequestBuilder

Post sets the Request method to POST and sets the given pathURL.

func (*RequestBuilder) Put

func (r *RequestBuilder) Put(pathURL string) *RequestBuilder

Put sets the Request method to PUT and sets the given pathURL.

func (*RequestBuilder) SetContentType

func (r *RequestBuilder) SetContentType(contentType string)

func (*RequestBuilder) SetHeader

func (r *RequestBuilder) SetHeader(key, value string) *RequestBuilder

Set sets the key, value pair in Headers, replacing existing values associated with key. Header keys are canonicalized.

func (*RequestBuilder) SetHeaders

func (r *RequestBuilder) SetHeaders(header http.Header) *RequestBuilder

func (*RequestBuilder) Subject

func (r *RequestBuilder) Subject(subject string) *RequestBuilder

func (*RequestBuilder) Trace

func (r *RequestBuilder) Trace(pathURL string) *RequestBuilder

Trace sets the Request method to TRACE and sets the given pathURL.

func (*RequestBuilder) Url

func (r *RequestBuilder) Url(url string) *RequestBuilder

Url extends the rawURL with the given path by resolving the reference to an absolute URL. If parsing errors occur, the rawURL is left unmodified.

type RequestInterface added in v1.0.54

type RequestInterface interface {
	GetUrl() string
	GetHeaders() http.Header
}

type RequestParams

type RequestParams map[string][]string

type Response

type Response struct {
	Status     string      `json:"reason"` // e.g. "200 OK"
	StatusCode int         `json:"code"`   // e.g. 200
	Headers    http.Header `json:"headers"`
	Body       []byte      `json:"body"`
}

Request is a simple struct

func (*Response) GetBody

func (r *Response) GetBody() []byte

func (*Response) GetHeaders

func (r *Response) GetHeaders() http.Header

func (*Response) GetStatusCode added in v1.0.54

func (r *Response) GetStatusCode() int

func (*Response) Header deprecated

func (r *Response) Header() http.Header

Deprecated: please use response builder instead

func (*Response) Write deprecated

func (r *Response) Write(b []byte) (n int, err error)

Deprecated: please use response builder instead

func (*Response) WriteHeader deprecated

func (r *Response) WriteHeader(code int)

Deprecated: please use response builder instead

type ResponseBuilder

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

Request is a simple struct

func NewResBuilder

func NewResBuilder() *ResponseBuilder

New returns a new default Request.

func NewResBuilderWithHeader added in v1.0.66

func NewResBuilderWithHeader(header http.Header) *ResponseBuilder

func (*ResponseBuilder) AddHeader

func (r *ResponseBuilder) AddHeader(key, value string) *ResponseBuilder

func (*ResponseBuilder) Body

func (r *ResponseBuilder) Body(body []byte) *ResponseBuilder

func (*ResponseBuilder) BodyJSON

func (r *ResponseBuilder) BodyJSON(bodyJSON interface{}) *ResponseBuilder

func (*ResponseBuilder) BodyProvider

func (r *ResponseBuilder) BodyProvider(body BodyProvider) *ResponseBuilder

BodyProvider sets the RequestBuilder's body provider.

func (*ResponseBuilder) Build

func (r *ResponseBuilder) Build() *Response

func (*ResponseBuilder) GetHeader

func (r *ResponseBuilder) GetHeader(key string) string

func (*ResponseBuilder) SetContentType

func (r *ResponseBuilder) SetContentType(value string)

func (*ResponseBuilder) SetCookie added in v1.0.63

func (r *ResponseBuilder) SetCookie(cookieValue string) *ResponseBuilder

func (*ResponseBuilder) SetHeader

func (r *ResponseBuilder) SetHeader(key, value string) *ResponseBuilder

func (*ResponseBuilder) StatusCode

func (r *ResponseBuilder) StatusCode(status int) *ResponseBuilder

type ResponseInterface added in v1.0.54

type ResponseInterface interface {
	Write(p []byte) (int, error)
	WriteHeader(status int)
	GetStatusCode() int
}

type Role

type Role string

func (Role) String

func (r Role) String() string

type Router

type Router interface {
	http.Handler
	// Deprecated: please use RegisterJson instead
	Register(method, pattern string, h HandlerFunc, a ...AuthFunc)
	RegisterJson(method, pattern string, h Handler, a ...AuthFunc)
	RegisterTopic(topic string, h Handler, a ...AuthFunc)
	Use(middlewares ...func(http.Handler) http.Handler)
}

type Server

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

func NewServer

func NewServer(subject string, options ...Option) *Server

func (*Server) Start

func (srv *Server) Start(started ...chan interface{})

func (*Server) Stop

func (srv *Server) Stop()

type ServerError

type ServerError interface {
	GetServerError() string
	GetServerErrorParam() interface{}
}

type String

type String struct {
	Value string
}

type UUID

type UUID string

func (UUID) String

func (u UUID) String() string

type UserInfo

type UserInfo struct {
	ExternalUserId  UUID                   `json:"externalUserId"` // as of now , it's for role patient only
	UserId          UUID                   `json:"userId"`
	CareProviderId  UUID                   `json:"careProviderId"`
	CareProviderKey string                 `json:"careProviderKey"`
	DeviceId        string                 `json:"deviceId"` // uuid format
	Role            Role                   `json:"role"`
	Attributes      map[string]interface{} `json:"attributes"`
}

func (UserInfo) CareProviderUUID

func (userInfo UserInfo) CareProviderUUID() *uuid.UUID

func (*UserInfo) GetSubject

func (u *UserInfo) GetSubject() string

func (UserInfo) UserUUID

func (userInfo UserInfo) UserUUID() *uuid.UUID

type ValidationError

type ValidationError struct {
	Namespace string      `json:"namespace"`
	Field     string      `json:"field"`
	Rule      string      `json:"rule"`
	Value     interface{} `json:"value"`
	Param     string      `json:"param"`
}

Directories

Path Synopsis
examples
Package log configures a new logger for an application.
Package log configures a new logger for an application.

Jump to

Keyboard shortcuts

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