fns

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: Apache-2.0 Imports: 28 Imported by: 8

README

Fns

简体中文


Fn services for Golang. Simplify the development process by using standardized development scheme. Every thing is function.

Features

  • Applicable to enterprise projects
    • Standardization
    • Environmental configuration
    • Rapid development by code generations
    • Built in authorizations service (schema is customizable)
    • Built in permission service
    • Built in metric
    • Built in tracing
    • Traceable and searchable error schema
    • Searchable log content schema
  • High concurrency
    • Goroutines pool
    • Fasthttp as default http server (Http3 is optionally)
    • Request Barrier (Used for sharing result and idempotent)
  • TLS
    • Standard
    • SSC (Auto generate cert and key by self sign ca)
    • ACMEs (Easy to use and supports auto-renew)
  • Cluster
    • Hazelcast
    • Redis
  • Official built-in services
    • SQL
      • Distributed SQL transaction
      • Postgres ORM
      • Mysql ORM
    • Redis
      • Shared store
      • Shared lockers
      • Shared barrier
    • Message queue
      • RabbitMQ
      • Kafka
      • Nats.IO
    • Third party integration
      • Oauth
      • Payments
      • SMS
      • Notifications

Quickstart

Creation

First: install fns commander.

go install github.com/aacfactory/fns/cmd/fns@latest

Second: use fns create a fns project.

mkdir {your project path}
cd {your project path}
fns init --mod={mod} . 

Third: look main.go, configs, modules to understand project structure.

Last: add dependencies and setup config.

Coding

First: create a service ident. Second: create a function. Last: run go generate to generate source codes.

Happy coding. Read usage for more.

Benchmark

CPU: AMD 3950X;
MEM: 64G;
RPS: 118850.991763/s;


          /\      |‾‾| /‾‾/   /‾‾/
     /\  /  \     |  |/  /   /  /
    /  \/    \    |     (   /   ‾‾\
   /          \   |  |\  \ |  (‾)  |
  / __________ \  |__| \__\ \_____/ .io

  execution: local
     script: ./test.js
     output: -

  scenarios: (100.00%) 1 scenario, 50 max VUs, 1m0s max duration (incl. graceful stop):
           * default: 50 looping VUs for 30s (gracefulStop: 30s)


running (0m30.0s), 00/50 VUs, 3565697 complete and 0 interrupted iterations
default ✓ [======================================] 50 VUs  30s

     ✓ status was 200

     checks.........................: 100.00% ✓ 3565697       ✗ 0
     data_received..................: 564 MB  19 MB/s
     data_sent......................: 521 MB  17 MB/s
     http_req_blocked...............: avg=1.58µs   min=0s med=0s   max=5.57ms   p(90)=0s      p(95)=0s
     http_req_connecting............: avg=24ns     min=0s med=0s   max=2.31ms   p(90)=0s      p(95)=0s
     http_req_duration..............: avg=261.31µs min=0s med=0s   max=12.92ms  p(90)=844.7µs p(95)=1ms
       { expected_response:true }...: avg=261.31µs min=0s med=0s   max=12.92ms  p(90)=844.7µs p(95)=1ms
     http_req_failed................: 0.00%   ✓ 0             ✗ 3565697
     http_req_receiving.............: avg=26.91µs  min=0s med=0s   max=8.65ms   p(90)=0s      p(95)=29.3µs
     http_req_sending...............: avg=10.53µs  min=0s med=0s   max=7.7ms    p(90)=0s      p(95)=0s
     http_req_tls_handshaking.......: avg=0s       min=0s med=0s   max=0s       p(90)=0s      p(95)=0s
     http_req_waiting...............: avg=223.86µs min=0s med=0s   max=12.43ms  p(90)=641.9µs p(95)=1ms
     http_reqs......................: 3565697 118850.991763/s
     iteration_duration.............: avg=412.23µs min=0s med=92µs max=118.81ms p(90)=1ms     p(95)=1ms
     iterations.....................: 3565697 118850.991763/s
     vus............................: 50      min=50          max=50
     vus_max........................: 50      min=50          max=50

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigActiveFromENV added in v0.1.1

func ConfigActiveFromENV(key string) (active string)

Types

type Application

type Application interface {
	Deploy(service ...services.Service) Application
	Run(ctx context.Context) Application
	Sync()
}

func New

func New(options ...Option) (app Application)

type Option

type Option func(*Options) error

func ConfigRetriever

func ConfigRetriever(path string, format string, active string, prefix string, splitter byte) Option

func Handler added in v1.1.0

func Handler(handler transports.MuxHandler) Option

func Hooks

func Hooks(h ...hooks.Hook) Option

func Id added in v0.14.0

func Id(id string) Option

func LogWriters added in v1.2.0

func LogWriters(writers ...logs.Writer) Option

func Middleware added in v1.1.0

func Middleware(middleware transports.Middleware) Option

func Name added in v0.14.0

func Name(name string) Option

func Proxy added in v1.0.10

func Proxy(options ...proxies.Option) Option

func RegisterValidator added in v0.12.0

func RegisterValidator(register validators.ValidateRegister) Option

func ShutdownTimeout added in v0.12.0

func ShutdownTimeout(timeout time.Duration) Option

func Transport added in v1.0.10

func Transport(transport transports.Transport) Option

func Version

func Version(version string) Option

type Options

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

Jump to

Keyboard shortcuts

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