Closed jafayer closed 1 week ago
Just a note that at some point the future we should probably find a way to do this more cleanly. Currently we're instantiating "request" timestamps when the Request object is created, then overriding them with the actual values that translate to the pre-data-event timestamps, representing network latency and deserialization. We may want to just allow the user to pass in timestamps to the request object?
See #25
This pull request introduces several enhancements and refactorings to improve the event handling system and network request processing. The key changes include the creation of a
TypedEventEmitter
class, updates to network handler interfaces, and the addition of request timing metadata.Event Handling Improvements:
src/common/core/events.ts
: IntroducedTypedEventEmitter
class to provide type-safe event handling.src/types/server.ts
: UpdatedDNSResponse
to extendTypedEventEmitter
and addedDNSResponseEvents
interface for type-safe events. [1] [2] [3]Network Handler Refactoring:
src/common/network/net.ts
: UpdatedNetworkHandler
interface to accept aDNSRequest
object instead of individual parameters. [1] [2]src/common/network/http.ts
: ModifiedDNSOverHTTP
to use the updatedNetworkHandler
interface and added request timing metadata. [1] [2] [3]src/common/network/tcp.ts
: UpdatedDNSOverTCP
to use the newNetworkHandler
interface and added request timing metadata. [1] [2] [3]src/common/network/udp.ts
: AdjustedDNSOverUDP
to utilize the updatedNetworkHandler
interface and included request timing metadata. [1] [2] [3]Example Update:
src/examples/helloWorld/index.ts
: AddedDNSOverHTTP
examples to the helloWorld example setup. [1] [2]