-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
141 additions
and
61 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
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,4 +1,4 @@ | ||
package app | ||
package frontend | ||
|
||
import ( | ||
"fmt" | ||
|
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package instance | ||
|
||
type EtcdMetadataBootstraper struct { | ||
RouterMetadataBootstraper | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package instance | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
type RouterMetadataBootstraper interface { | ||
InitializeMetadata(ctx context.Context, r RouterInstance) error | ||
} |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package instance | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pg-sharding/spqr/pkg/spqrlog" | ||
"github.com/pg-sharding/spqr/router/client" | ||
) | ||
|
||
type InitSQLMetadataBootstraper struct { | ||
InitSQLFIle string | ||
} | ||
|
||
// InitializeMetadata implements RouterMetadataBootstraper. | ||
func (i *InitSQLMetadataBootstraper) InitializeMetadata(ctx context.Context, r RouterInstance) error { | ||
for _, fname := range []string{ | ||
// rcfg.InitSQL, | ||
i.InitSQLFIle, | ||
} { | ||
if len(fname) == 0 { | ||
continue | ||
} | ||
queries, err := r.Console().Qlog().Recover(ctx, fname) | ||
if err != nil { | ||
spqrlog.Zero.Error().Err(err).Msg("failed to initialize router") | ||
return err | ||
} | ||
|
||
spqrlog.Zero.Info().Msg("executing init sql") | ||
for _, query := range queries { | ||
spqrlog.Zero.Info().Str("query", query).Msg("") | ||
if err := r.Console().ProcessQuery(ctx, query, client.NewFakeClient()); err != nil { | ||
spqrlog.Zero.Error().Err(err).Msg("") | ||
} | ||
} | ||
|
||
spqrlog.Zero.Info(). | ||
Int("count", len(queries)). | ||
Str("filename", fname). | ||
Msg("successfully init queries from file") | ||
} | ||
|
||
r.Initialize() | ||
|
||
return nil | ||
} | ||
|
||
func NewInitSQLMetadataBootstraper(InitSQLFIle string) RouterMetadataBootstraper { | ||
return &InitSQLMetadataBootstraper{ | ||
InitSQLFIle: InitSQLFIle, | ||
} | ||
} | ||
|
||
var _ RouterMetadataBootstraper = &InitSQLMetadataBootstraper{} |
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,4 +1,4 @@ | ||
package app | ||
package instance | ||
|
||
import ( | ||
"io" | ||
|
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
Oops, something went wrong.