Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Not able to use custom plugin with composite architecture approac… #2300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pkg/apisix/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func newCluster(ctx context.Context, o *ClusterOptions) (Cluster, error) {
c.upstreamServiceRelation = newUpstreamServiceRelation(c)
c.pluginMetadata = newPluginMetadataMem(c)

c.validator, err = NewReferenceFile("conf/apisix-schema.json")
c.validator = newDummyValidator()
if err != nil {
return nil, err
}
Expand All @@ -204,6 +204,8 @@ func newCluster(ctx context.Context, o *ClusterOptions) (Cluster, error) {
return nil, err
}
go c.adapter.Serve(ctx, ln)
go c.syncSchema(ctx, o.SyncInterval.Duration)

} else {
c.route = newRouteClient(c)
c.upstream = newUpstreamClient(c)
Expand Down Expand Up @@ -438,6 +440,17 @@ func (c *cluster) HasSynced(ctx context.Context) error {

// syncSchema syncs schema from APISIX regularly according to the interval.
func (c *cluster) syncSchema(ctx context.Context, interval time.Duration) {
for {
if err := c.syncSchemaOnce(ctx); err != nil {
log.Errorf("failed to sync schema on startup: %s", err)
c.metricsCollector.IncrSyncOperation("schema", "failure")
// 等待 2 秒后重试
time.Sleep(2 * time.Second)
continue // 继续重试
}
break // 如果同步成功,退出循环
}

ticker := time.NewTicker(interval)
defer ticker.Stop()

Expand Down