feat: backend executor implement
This commit is contained in:
@@ -175,7 +175,9 @@ const serverConfiguration8081 = `http {
|
||||
`
|
||||
|
||||
type memoryGateway struct {
|
||||
snapshot hostnginx.Snapshot
|
||||
snapshot hostnginx.Snapshot
|
||||
applyCount int
|
||||
beforeApply func(hostnginx.Snapshot) error
|
||||
}
|
||||
|
||||
func (g *memoryGateway) Read() (hostnginx.Snapshot, error) {
|
||||
@@ -183,7 +185,13 @@ func (g *memoryGateway) Read() (hostnginx.Snapshot, error) {
|
||||
}
|
||||
|
||||
func (g *memoryGateway) Apply(_ context.Context, snapshot hostnginx.Snapshot) error {
|
||||
if g.beforeApply != nil {
|
||||
if err := g.beforeApply(snapshot); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
g.snapshot = hostnginx.Snapshot{Content: append([]byte(nil), snapshot.Content...), ActivePort: snapshot.ActivePort}
|
||||
g.applyCount++
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user