fieldalignment of all structs to save memory

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-04-27 08:32:47 +03:00
parent ee11f39a2f
commit 86626c5922
78 changed files with 343 additions and 410 deletions

View File

@@ -9,12 +9,10 @@ import (
"github.com/unistack-org/micro/v3/meter"
)
var (
// guard to fail early
_ MeterServer = &handler{}
)
// guard to fail early
var _ MeterServer = &Handler{}
type handler struct {
type Handler struct {
opts Options
}
@@ -52,12 +50,12 @@ func NewOptions(opts ...Option) Options {
return options
}
func NewHandler(opts ...Option) *handler {
func NewHandler(opts ...Option) *Handler {
options := NewOptions(opts...)
return &handler{opts: options}
return &Handler{opts: options}
}
func (h *handler) Metrics(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error {
func (h *Handler) Metrics(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error {
buf := bytes.NewBuffer(nil)
if err := h.opts.Meter.Write(buf, h.opts.MeterOptions...); err != nil {
return errors.InternalServerError(h.opts.Name, "%v", err)