generated from dogmatiq/template-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update tests to work with new message formats.
- Loading branch information
Showing
24 changed files
with
195 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,71 @@ | ||
package staticconfig | ||
|
||
import ( | ||
"github.com/dogmatiq/dogma" | ||
"github.com/dogmatiq/enginekit/config" | ||
"github.com/dogmatiq/enginekit/config/internal/configbuilder" | ||
"github.com/dogmatiq/enginekit/config/staticconfig/internal/ssax" | ||
) | ||
|
||
func analyzeHandler[T configbuilder.HandlerBuilder]( | ||
ctx *configurerCallContext[*configbuilder.ApplicationBuilder], | ||
build func(func(T)), | ||
analyze configurerCallAnalyzer[T], | ||
func analyzeHandler[ | ||
T config.Handler, | ||
H any, | ||
B configbuilder.HandlerBuilder[T, H], | ||
]( | ||
ctx *configurerCallContext[*config.Application, dogma.Application, *configbuilder.ApplicationBuilder], | ||
build func(func(B)), | ||
analyze configurerCallAnalyzer[T, H, B], | ||
) { | ||
build(func(b T) { | ||
b.UpdateFidelity(ctx.Fidelity) | ||
build(func(b B) { | ||
if ctx.IsSpeculative { | ||
b.Speculative() | ||
} | ||
|
||
t := ssax.ConcreteType(ctx.Args[0]) | ||
|
||
if !t.IsPresent() { | ||
b.UpdateFidelity(config.Incomplete) | ||
b.Partial() | ||
return | ||
} | ||
|
||
analyzeEntity( | ||
ctx.context, | ||
t.Get(), | ||
b, | ||
func(ctx *configurerCallContext[T]) { | ||
func(ctx *configurerCallContext[T, H, B]) { | ||
switch ctx.Method.Name() { | ||
case "Routes": | ||
analyzeRoutes(ctx) | ||
|
||
case "Disable": | ||
// TODO(jmalloc): f is lost in this case, so any handler | ||
// that is _sometimes_ disabled will appear as always | ||
// disabled, which is a bit non-sensical. | ||
// | ||
// It probably needs similar treatment to | ||
// https://github.com/dogmatiq/enginekit/issues/55. | ||
ctx.Builder.SetDisabled(true) | ||
ctx.Builder.Disabled( | ||
func(b *configbuilder.FlagBuilder[config.Disabled]) { | ||
if ctx.IsSpeculative { | ||
b.Speculative() | ||
} | ||
b.Value(true) | ||
}, | ||
) | ||
|
||
default: | ||
if analyze == nil { | ||
ctx.Builder.UpdateFidelity(config.Incomplete) | ||
ctx.Builder.Partial() | ||
} else { | ||
analyze(ctx) | ||
} | ||
} | ||
}, | ||
) | ||
|
||
// If the handler wasn't disabled, and the configuration is NOT | ||
// incomplete, we know that the handler is enabled. | ||
if !b.IsDisabled().IsPresent() && b.Fidelity()&config.Incomplete == 0 { | ||
b.SetDisabled(false) | ||
} | ||
}) | ||
} | ||
|
||
func analyzeProjectionConfigurerCall( | ||
ctx *configurerCallContext[*configbuilder.ProjectionBuilder], | ||
ctx *configurerCallContext[*config.Projection, dogma.ProjectionMessageHandler, *configbuilder.ProjectionBuilder], | ||
) { | ||
switch ctx.Method.Name() { | ||
case "DeliveryPolicy": | ||
panic("not implemented") // TODO | ||
default: | ||
ctx.Builder.UpdateFidelity(config.Incomplete) | ||
ctx.Builder.Partial() | ||
} | ||
} |
Oops, something went wrong.