Documentation ¶
Index ¶
- Constants
- func Config() *sync.Map
- func ConfigIn(keyPath string) interface{}
- func ImportConfigFilesFromDirectory(dir string) error
- func ImportConfigFromPaths(paths ...string) error
- func LoadConfigFromFile(path string, into interface{}) (err error)
- func Logger(name string) *log.Logger
- func Metric() *statsd.Client
- func MetricCount(key string, num interface{})
- func MetricDecrease(key string)
- func MetricGauge(bucket string, value interface{})
- func MetricHistogram(bucket string, value interface{})
- func MetricIncrease(key string)
- func MetricTimeDuration(key string, duration time.Duration)
- func MetricTiming(key string, value interface{})
- type Application
- type PanicHandler
- type Service
- func (s *Service) Connect(fn ...iris.Handler) *Service
- func (s *Service) Delete(fn ...iris.Handler) *Service
- func (s *Service) Get(fn ...iris.Handler) *Service
- func (s *Service) HandleDir(dir string, opts ...router.DirOptions)
- func (s *Service) Head(fn ...iris.Handler) *Service
- func (s *Service) Option(fn ...iris.Handler) *Service
- func (s *Service) Patch(fn ...iris.Handler) *Service
- func (s *Service) Post(fn ...iris.Handler) *Service
- func (s *Service) Put(fn ...iris.Handler) *Service
- func (s *Service) Trace(fn ...iris.Handler) *Service
- type ServiceGroup
Constants ¶
const ( ErrNameApplicationInitFailure = "rock.Application.InitFailure" ErrNameUnsupportedFormat = "unsupported format" )
const ConfigFilename = "rockgo"
Variables ¶
This section is empty.
Functions ¶
func ConfigIn ¶
func ConfigIn(keyPath string) interface{}
Find value from shared configs with <keyPath> delimited by ".".
func ImportConfigFilesFromDirectory ¶
Load each file in the <dir> without recursive by ImportConfigFromPaths(). Contents of file would be stored in shared config with filename (without extension). e.g. app.yaml would use "app" as key. - Return: each got error
func ImportConfigFromPaths ¶
ImportConfigFromPaths load multiple config files. And then store in a shared map with key by filename (stripped ext), e.g. abc for abc.json. - Parameters:
- paths: Path list to be loaded, empty string would be ignored.
- Return: each got error
func LoadConfigFromFile ¶
LoadConfigFromFile support json and yaml format with extension (json/yaml/yml)
func Logger ¶
Logger would return initialized logger with <name> from rock config, you should call it after NewApplication. - Return: Named logger, or default logger.
func Metric ¶
func Metric() *statsd.Client
Metric pass statsd client to make custom record.
- Return: may be nil if not calling rock.Application#InitWithConfig() or not configure correctly.
func MetricCount ¶
func MetricCount(key string, num interface{})
MetricCount would change count on <num> for key.
func MetricDecrease ¶
func MetricDecrease(key string)
MetricDecrease would decrease count on 1 for key with statsd count.
func MetricGauge ¶
func MetricGauge(bucket string, value interface{})
func MetricHistogram ¶
func MetricHistogram(bucket string, value interface{})
func MetricIncrease ¶
func MetricIncrease(key string)
MetricIncrease would increase count on 1 for key with statsd count.
func MetricTimeDuration ¶ added in v0.2.1
MetricTimeDuration would record time duration for key with statsd timing.
- Parameters:
- duration: e.g. time.Now().Sub(oldTime) or time.Second * 4
func MetricTiming ¶
func MetricTiming(key string, value interface{})
Types ¶
type Application ¶
type Application interface { // Name returns app_name in rockgo config. Name() string // Iris returns iris application. Iris() *iris.Application // Set panic handler, it would working on sentry.repanic is true only. SetPanicHandler(fn PanicHandler) // Serve make Service to register handler. // // - Parameters: // - name: for statsd // - path: path from root, e.g. "foo" for "/foo" Serve(name, path string) *Service // ServeGroup make ServiceGroup to handle multiple Services like directory. // // - Parameters: // - name: for statsd // - path: directory name in path from root ServeGroup(name, path string) *ServiceGroup // Run server with <host> and multiple [conf]. // // - Parameters: // - host: [server name] with port. e.g. "mydomain.com:80" or ":8080" (equal "0.0.0.0:8080") Run(host string, conf ...host.Configurator) error }
func NewApplication ¶
func NewApplication(configDir string) (Application, error)
NewApplication would load config files from <configDir>, and then make Application with rockgo.yaml (or json) in <configDir>.
type PanicHandler ¶
type PanicHandler func(ctx iris.Context, err error)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
type ServiceGroup ¶
type ServiceGroup struct {
// contains filtered or unexported fields
}
func (*ServiceGroup) Serve ¶
func (g *ServiceGroup) Serve(name, path string) *Service
func (*ServiceGroup) ServeGroup ¶
func (g *ServiceGroup) ServeGroup(name, path string) *ServiceGroup
func (*ServiceGroup) Use ¶
func (g *ServiceGroup) Use(mw ...iris.Handler) *ServiceGroup
Use middlewares into application or party.