narada

package module
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: MIT Imports: 19 Imported by: 0

README

🖖🚀 Narada

Rapid web development, all in one place

Go Report Card GoDoc Build Status Coverage Status

What is under the hood?

Under the hood a lot of different and cool packages such as:

  • Logrus
  • Go-PG
  • Go-redis
  • Uber FX
  • Viper
  • Sentry
  • Pprof
  • Prometheus

Also it supports:

  • Workers using chapsuk workers package
  • Http.Handler binding and serving

Modules

Config

Dependency: *viper.Viper
Configuration:
Configuration file are located at NARADA_CONFIG or config.yml.
Environment BINDING_API will be replaced to binding.api.

Logger

Dependency: *logrus.Logger
Configuration:

logger: 
    formatter: text # Supported values ['text', 'json']
    level: debug # Supported values ['debug', 'info', 'warn', 'error']
    catch_errors: true # Sending >=error level to sentry
    slack: false # Sending >= error level to slack 
    slack_url: "" # Slack webhook url [Required when slack is true]
    slack_icon: ""
    slack_emoji: ":ghost:"
    slack_username: "<YOUR_APP_NAME>_bot"
    slack_channel: "" #  Slack username [Required when slack is true]
Workers

This module generates

Dependency: *narada.Workers

Clients

Here all clients that are provided automatically located.

Redis

Dependency: *redis.Client Configuration:

redis:
    addr: "" # Redis address, in e.g.: 127.0.0.1:6379
    db: 0
    password: ""
    pool_size: 10
    idle_timeout: 60s
PostgreSQL

Dependency: *pg.DB
Configuration:

database:
    addr: "" # PostgreSQL address
    user: ""
    password: ""
    database: ""
    pool: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfig

func NewConfig() (*viper.Viper, error)

NewConfig creates a new configuration, by default config file will be `config.yml` in same directory you run application if you want to override it you should provide `NARADA_CONFIG` environment variable.

func NewLogger

func NewLogger(config *viper.Viper) (*logrus.Logger, error)

func NewMetricsInvoke

func NewMetricsInvoke(ms *Multiserver) error

func NewNopLogger

func NewNopLogger() *logrus.Logger

func NewProfilerInvoke

func NewProfilerInvoke(ms *Multiserver) error

func NewSentryInvoke added in v0.1.2

func NewSentryInvoke(config *viper.Viper, lc fx.Lifecycle) error

Types

type LogrusSentryHook

type LogrusSentryHook struct {
}

func NewLogrusSentryHook

func NewLogrusSentryHook() LogrusSentryHook

func (LogrusSentryHook) Fire

func (h LogrusSentryHook) Fire(entry *logrus.Entry) error

func (LogrusSentryHook) Levels

func (h LogrusSentryHook) Levels() []logrus.Level

type LogrusSlackHook

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

func NewLogrusSlackHook

func NewLogrusSlackHook(config *viper.Viper) LogrusSlackHook

func (LogrusSlackHook) Fire

func (h LogrusSlackHook) Fire(entry *logrus.Entry) error

func (LogrusSlackHook) Levels

func (h LogrusSlackHook) Levels() []logrus.Level

type Multiserver

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

func NewMultiServers

func NewMultiServers(config *viper.Viper, logger *logrus.Logger, lc fx.Lifecycle) (*Multiserver, error)

func (*Multiserver) Add

func (ms *Multiserver) Add(name string, handler http.Handler) error

type Narada

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

func New

func New(name string, version string, providers ...interface{}) *Narada

func (Narada) HandleError

func (t Narada) HandleError(err error)

func (*Narada) Invoke added in v0.1.7

func (t *Narada) Invoke(fn interface{})

func (*Narada) Start

func (t *Narada) Start(fn interface{})

func (*Narada) Stop

func (t *Narada) Stop()

type SlackAttachment

type SlackAttachment struct {
	Title    string        `json:"title"`
	Fallback string        `json:"fallback"`
	Text     string        `json:"text"`
	Pretext  string        `json:"pretext"`
	Color    string        `json:"color"`
	Fields   []*SlackField `json:"fields"`
}

func NewAttachment

func NewAttachment() *SlackAttachment

func (*SlackAttachment) AddField

func (a *SlackAttachment) AddField(f *SlackField)

type SlackClient

type SlackClient struct {
	Url string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url string) *SlackClient

func (*SlackClient) SendMessage

func (c *SlackClient) SendMessage(msg *SlackMessage) error

type SlackError

type SlackError struct {
	Code int
	Body string
}

func (*SlackError) Error

func (e *SlackError) Error() string

type SlackField

type SlackField struct {
	Title string `json:"title"`
	Value string `json:"value"`
	Short bool   `json:"short"`
}

func NewField

func NewField() *SlackField

type SlackMessage

type SlackMessage struct {
	Text        string             `json:"text"`
	Username    string             `json:"username"`
	IconUrl     string             `json:"icon_url"`
	IconEmoji   string             `json:"icon_emoji"`
	Channel     string             `json:"channel"`
	UnfurlLinks bool               `json:"unfurl_links"`
	Attachments []*SlackAttachment `json:"attachments"`
}

func (*SlackMessage) AddAttachment

func (m *SlackMessage) AddAttachment(a *SlackAttachment)

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

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