Skip to content

Latest commit

 

History

History
63 lines (46 loc) · 2.32 KB

File metadata and controls

63 lines (46 loc) · 2.32 KB

Examples

简体中文 | Docs Index

Example 1: Add the Module to an Application

mkdir gnalloy-app && cd gnalloy-app
go mod init example.com/gnalloy-app
go get gnalloy.org/protocol@dev
go doc gnalloy.org/protocol

Example 2: Inspect Current Packages

The current source tree exposes these package import paths:

  • gnalloy.org/protocol

Use go doc against the package that matches the behavior you need:

go doc gnalloy.org/protocol

Selected current exported entry points:

  • var ErrInvalidConfig = errors.New("gnalloy/protocol: invalid config") ...
  • func NewServerHandler(adapter ServerAdapter, handler Handler) channel.Handler
  • type Adapter interface{ ... }
  • type ChannelExchanger struct{ ... }
  • type DatagramAdapter struct{}
  • type FrameAdapter struct{}

Example 3: Use Executable Tests as Behavioral Examples

Repository tests are executable examples of supported behavior. Start with the selected names below, then read the matching _test.go files for complete setup and assertions. See Testing and Performance for the complete discovered list.

GOWORK=off GOTOOLCHAIN=local go test ./... -run Test -count=1

Selected current test, benchmark, fuzz, and example entry points:

  • TestChannelExchangerAdapters
  • TestChannelExchangerRejectsInvalidConfig
  • TestServerAdaptersRespondWithTransportMetadata
  • TestServerBindInstallsProtocolHandler
  • TestServerRejectsInvalidConfig

Example 4: Cross-Module Assembly

Direct Gnalloy dependencies for this module:

  • gnalloy.org/gnalloy
  • gnalloy.org/transport-l2
  • gnalloy.org/transport-raw
  • gnalloy.org/transport-udp

Assembly guidance:

  • Use this protocol module to assemble transport-neutral request-response behavior over streams or datagrams.
  • Keep concrete transports, codecs, and handlers in separate modules and wire them at application boundaries.
  • Use tests as the authority for timeout, correlation, exchange, and lifecycle behavior.

Example 5: Pressure-Test Harness

For sustained load, wire this module into a scenario under gnalloy.org/benchmarks or a runnable client under gnalloy.org/examples when the module participates in network traffic. Record host, OS, CPU, Go version, protocol, payload, concurrency, warmup, repetitions, throughput, and p99 latency in the report.