Skip to content

Latest commit

 

History

History
82 lines (65 loc) · 3.49 KB

File metadata and controls

82 lines (65 loc) · 3.49 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/codec-http3@dev
go doc gnalloy.org/codec-http3

Example 2: Inspect Current Packages

The current source tree exposes these package import paths:

  • gnalloy.org/codec-http3
  • gnalloy.org/codec-http3/http1bridge

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

go doc gnalloy.org/codec-http3
go doc gnalloy.org/codec-http3/http1bridge

Selected current exported entry points:

  • const DefaultMaxFrameSize = 16 * 1024 * 1024 ...
  • const HandlerNameHTTP3FrameDecoder = "http3-frame-decoder" ...
  • const SettingQPACKMaxTableCapacity uint64 = 0x01 ...
  • const SettingEnableConnectProtocol uint64 = 0x08 ...
  • const WebTransportProtocolH3 = "webtransport-h3" ...
  • var ErrInvalidFrame = errors.New("http3: invalid frame") ...
  • var ErrInvalidHeadersBlock = errors.New("gnalloy/codec/http3/http1bridge: invalid headers block")
  • func HeadersBlockFromRequest(req http1.Request, scheme string) http3.HeadersBlock
  • func HeadersBlockFromResponse(resp http1.Response) http3.HeadersBlock
  • func HeadersBlockFromTrailers(trailers http1.Headers) http3.HeadersBlock
  • func RequestFromHeadersBlock(block http3.HeadersBlock) (http1.Request, error)
  • func ResponseFromHeadersBlock(block http3.HeadersBlock) (http1.Response, error)

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:

  • BenchmarkDecoderDataFrame
  • BenchmarkHeaderDecoderFragmentedBlock
  • FuzzHTTP3FramePipeline
  • TestAppendAndDecodePushPromise
  • TestControlStreamRejectsDataAfterSettings
  • TestControlStreamRequiresSettingsFirst
  • TestDecoderParsesDataFrameZeroCopy
  • TestDecoderParsesSettingsAndRejectsDuplicate
  • TestEncoderWritesHeadersFrameWithoutCopyingPayload
  • TestFrameToHTTPObjectCodecClientOutboundObjectStream
  • TestFrameToHTTPObjectCodecServerInboundObjectStream
  • TestHeaderCodecRoundTripHeadersBlock
  • TestHeaderCodecRoundTripPushPromiseBlock
  • TestHeaderDecoderEnforcesHeaderListSize
  • TestHeaderDecoderUsesReadableSlicesInsteadOfBytes
  • TestHTTP3PipelineRejectsInvalidConfig
  • TestLifecycleHandlerFiresControlEventsAndPropagatesFrames
  • TestLocalControlStreamPipelineWritesSettingsOnActive

Example 4: Cross-Module Assembly

Direct Gnalloy dependencies for this module:

  • gnalloy.org/codec-http1
  • gnalloy.org/gnalloy

Assembly guidance:

  • Use this codec above a byte-oriented or datagram transport and below application handlers.
  • The codec converts bytes or Gnalloy messages into protocol objects and converts outbound protocol objects back to bytes.
  • It does not open sockets, own EventLoops, or define application lifecycle.

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.