Autogenerate server for GoLang written services logic functions
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd
error
parser
.gitignore
0-make-new-project.go
1-update-project-template.go
2-generate-server.go
3-generate-sdk.go
LICENSE
OSI-application-CoAP.go
OSI-application-DNS.go
OSI-application-GraphQL.go
OSI-application-HTTP.go
OSI-application-MQTT.go
OSI-application-RAW.go
OSI-application-RPC.go
OSI-application-SOAP.go
OSI-application-gRPC.go
OSI-application-jsonrpc.go
OSI-application-sAPP.go
OSI-application-sRPC.go
OSI-network-IPv6.go
OSI-transport-SCP.go
README.md
authorization-request.go
chaparkhane-manifest.go
documentation-openapi.go
errors-build.go
errors.go
firewall.go
make-sdk-c.go
make-sdk-dart.go
make-sdk-go.go
make-sdk-ts.go
make-server.go
server-connection-data.go
server-connection-pool.go
server-methods-0-register-guest-connection.go
server-methods-1-revoke-connection.go
server-methods-2-close-connection.go
server-methods-3-ping-peer.go
server-methods-4-set-settings.go
server-methods-5-get-streams-id.go
server-methods-6-close-stream.go
server-methods-7-set-stream-weight.go
server-methods-8-set-stream-time-sensitive.go
server-methods-9-resend-broken-packet.go
server-methods-handler.go
server-packet-data.go
server-stream-data.go
server.go
template-error-beauty.go
validate-data.go

README.md

ChaparKhane

Autogenerate Multi Network Handlers for GoLang written Services Logic Methods in specific template like this. It will also make SDK in multi language for client usage.

Supported Protocol

All information get from IANA Resources like IP Protocols, Transport Protocols, ... But we don't support all of them due many problem in their architecture.

SCP transport protocol

SCPTransportProtocol is our experimental open-source named SabzCityProtocol!! In IPv6 every service have unique IP, So we don't need layer between SCP & IPv6! It is huge advantage and improve app network performance!

sRPC application protocol

sRPC application protocol is our experimental SabzCity remote procedure call protocol with almost not any overhead!

How to use!

As A Service

Call needed service functions in files that start with number in chaparkhane repo.

SabzCity Version Control

  • Add ChaparKhane as dependency to project.

Git

First Time!

  • Make project version control by git init
  • Add ChaparKhane to project as submodule by git submodule add -b master https://github.com/SabzCity/ChaparKhane-go
  • Run ChaparKhane to initialize project by go run ./ChaparKhane/cmd -MethodID=0
  • Complete manifest in main package of service.
  • Add other data to main package if needed.
  • Copy template file as number you need in logic package folder, replace method name in file name and function with your desire name and add business logic to them!
  • As you can see in template file logic layers are independent layer and you must just think locally! But if you need network request data use rpd *chaparkhane.ReceivedPacketData in your each function parameters. Don't remove it even don't need it!
    CAUTION : DON'T REUSE OLD FUNCTION ID EVEN IF YOU REMOVE FUNCTION IN NEW VERSION!
  • Run go run ./ChaparKhane/cmd -MethodID=2 to generate server with your desire options.
  • Run go run ./ChaparKhane/cmd -MethodID=3 to generate SDK if you want!
  • Build & run your server. Change {{AppName}} with desire name.
go build -o ./build/{{AppName}}{{.exe}}
./{{AppName}}{{.exe}}

After first time!

  • Clone exiting project with git clone [<repository path>] --recursive --shallow-submodules
  • Make needed changes in app logic or add new method.
  • Change ChaparKhane version by git checkout tag/{{tag}} or update by git submodule update -f --init --remote --checkout --recursive if needed.
  • Run ChaparKhane to update project template by go run ./ChaparKhane/cmd -MethodID=1 if you want!
  • Run go run ./ChaparKhane/cmd -MethodID=2 to generate server with your desire options.
  • Run go run ./ChaparKhane/cmd -MethodID=3 to generate SDK if you want!
  • Build & run your server. Change {{AppName}} with desire name.
go build -o ./build/{{AppName}}{{.exe}}
./{{AppName}}{{.exe}}

Done in autogenerate layers

  • Serialize and deserialize data format like json, xml, binary, ... would be faster up to 5x because of not use of reflection
    e.g. https://github.com/mailru/easyjson , https://github.com/pquerna/ffjson
  • Check & validate request data
  • Make handlers to receive data and call logic methods.
  • Make API documentation in many standards e.g. OpenAPI(Swagger), ...
  • Make SDK in multi language & system e.g. Go, JS, ...

Architecure details

Connection

  • Peer can open connection in 0ms and send data just after send open connection. However if first stream to open connection lost for delay after send data stream follow stream will drop! So it is better to wait open connection response after that start sending data.
  • How user make a new connection in SCP

Microservice version

We use git tag to determine last version of every microservice. Each microservice must have a tag on each version. e.g. v0.0.1-alpha

Build rules

  • If commit set as the version tag, All logic methods must be bug free, Otherwise Building will be failed with error!
  • If commit not set as the version tag, Each methods has error will be eliminate from building process with error!

Security

  • Everything only can run in security protocol like TLS. we force redirect http to https requests.

Compress

To achieve better bandwidth we force to compress request and answer. e.g. gzip

Management and analitics

Logging

Caching

We just cache HTTP GET method. we must work to cache other get method.

AI

Security

  • Quic Security Considerations
  • Track multi broken stream as kind of attack.
  • Track for try to open multi guest connections. guest user can just one connection per IP.
  • Track for stream fragmentation and reassembly attacks.
  • Track for changed IP more than twice in little time! It may connection information had been leaked!

What is prohibited?

  • Autogenerated code should not be edited, since it may be automatically overwritten by the same process.
  • Don't use minor version for service breaking changes! We just use major version number to versioning API.

Production ready!?

This package is under development and not ready to use in real production. It can have breakable changes until version 1 release. But we are glad to hear your experience or idea about this package. So please feedback us!

ChaparKhane word meaning

"Chapar Khaneh" (Persian: چاپارخانه‎, IPA: [tʃɒːˈpɒːɾ xɒːˈne], courier-house) is a Persian term for the postal service used during the Achaemenid era. The system was created by Cyrus the Great, the founder of the Persian Empire, and later developed by Darius the Great, as the royal method of communication throughout the empire. Each "Chapar Khaneh" was a station mainly located along the Royal Road, a 2500 km ancient highway, which stretched from the Sardis to Susa, connecting most of the major cities of the empire.