Skip to content

Introduce options patterns#786

Merged
JoTurk merged 1 commit intomasterfrom
options-patterns
Feb 4, 2026
Merged

Introduce options patterns#786
JoTurk merged 1 commit intomasterfrom
options-patterns

Conversation

@JoTurk
Copy link
Copy Markdown
Member

@JoTurk JoTurk commented Jan 22, 2026

Description

(not ready for review, I'll double review this when i wake up).
This introduces options patterns to DTLS. it's a bit tricky because dtls options are a bit complex:

  1. Like ICE we apply the defaults first, then we do validations in the options calls.
  2. Like MDNS we have client and servers options, and overlapping options between the two.
  3. like transport we're introducing WithOptions helpers, and in the next major release we're going to depreciate this suffix, and change the current constructors to options first.

Updated all examples and the e2e test.

resolves: #765

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 22, 2026

Codecov Report

❌ Patch coverage is 79.14110% with 68 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.65%. Comparing base (9495bef) to head (0a5b311).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
options.go 82.97% 48 Missing ⚠️
resume.go 0.00% 7 Missing and 2 partials ⚠️
listener.go 36.36% 6 Missing and 1 partial ⚠️
conn.go 83.33% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #786      +/-   ##
==========================================
- Coverage   81.72%   81.65%   -0.07%     
==========================================
  Files         108      109       +1     
  Lines        6062     6384     +322     
==========================================
+ Hits         4954     5213     +259     
- Misses        712      771      +59     
- Partials      396      400       +4     
Flag Coverage Δ
go 81.65% <79.14%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adrianosela
Copy link
Copy Markdown
Contributor

This is awesome @JoTurk , thank you for taking the time to do this!

@JoTurk JoTurk marked this pull request as ready for review February 4, 2026 04:30
@JoTurk
Copy link
Copy Markdown
Member Author

JoTurk commented Feb 4, 2026

Okay i reviewed this few times and i think it's consistent with our other options patters, I'll add more coverage before merge but i think this is ready for review.

@philipch07 @adrianosela @theodorsm

@JoTurk JoTurk requested a review from Sean-Der February 4, 2026 04:33
Copy link
Copy Markdown
Contributor

@adrianosela adrianosela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is amazing - 🚢 it!

@JoTurk JoTurk merged commit 0a5b311 into master Feb 4, 2026
27 of 29 checks passed
@JoTurk JoTurk deleted the options-patterns branch February 4, 2026 06:51
OnConnectionAttempt: c.onConnectionAttempt,
}

if len(c.certificates) > 0 {
Copy link
Copy Markdown
Contributor

@adrianosela adrianosela Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that we are defensively copying twice. Not a big deal - but we don't need to AFAICT. (we are doing a copy when setting the option on dtlsConfig, so no need to copy again here)

cc:// @JoTurk

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove the other copy, and make it copy for the old API, i'll make a PR for more cleanup and to update the tests. hopefully we can remove the other API sooner so we don't have to maintain both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config pattern

2 participants