| //Copyright 2017 Huawei Technologies Co., Ltd |
| // |
| //Licensed under the Apache License, Version 2.0 (the "License"); |
| //you may not use this file except in compliance with the License. |
| //You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| //Unless required by applicable law or agreed to in writing, software |
| //distributed under the License is distributed on an "AS IS" BASIS, |
| //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| //See the License for the specific language governing permissions and |
| //limitations under the License. |
| package buildin |
| |
| import ( |
| "fmt" |
| "github.com/ServiceComb/service-center/pkg/util" |
| "github.com/ServiceComb/service-center/server/infra/registry" |
| mgr "github.com/ServiceComb/service-center/server/plugin" |
| "golang.org/x/net/context" |
| ) |
| |
| func init() { |
| mgr.RegisterPlugin(mgr.Plugin{mgr.STATIC, mgr.REGISTRY, "buildin", NewRegistry}) |
| } |
| |
| var noClientPluginErr = fmt.Errorf("register center client plugin does not exist") |
| |
| type ErrorRegisterCenterClient struct { |
| ready chan int |
| } |
| |
| func (ec *ErrorRegisterCenterClient) safeClose(chan int) { |
| defer util.RecoverAndReport() |
| close(ec.ready) |
| } |
| func (ec *ErrorRegisterCenterClient) Err() (err <-chan error) { |
| return |
| } |
| func (ec *ErrorRegisterCenterClient) Ready() <-chan int { |
| ec.safeClose(ec.ready) |
| return ec.ready |
| } |
| func (ec *ErrorRegisterCenterClient) PutNoOverride(ctx context.Context, opts ...registry.PluginOpOption) (bool, error) { |
| return false, noClientPluginErr |
| } |
| func (ec *ErrorRegisterCenterClient) Do(ctx context.Context, opts ...registry.PluginOpOption) (*registry.PluginResponse, error) { |
| return nil, noClientPluginErr |
| } |
| func (ec *ErrorRegisterCenterClient) Txn(ctx context.Context, ops []registry.PluginOp) (*registry.PluginResponse, error) { |
| return nil, noClientPluginErr |
| } |
| func (ec *ErrorRegisterCenterClient) TxnWithCmp(ctx context.Context, success []registry.PluginOp, cmp []registry.CompareOp, fail []registry.PluginOp) (*registry.PluginResponse, error) { |
| return nil, noClientPluginErr |
| } |
| func (ec *ErrorRegisterCenterClient) LeaseGrant(ctx context.Context, TTL int64) (leaseID int64, err error) { |
| return 0, noClientPluginErr |
| } |
| func (ec *ErrorRegisterCenterClient) LeaseRenew(ctx context.Context, leaseID int64) (TTL int64, err error) { |
| return 0, noClientPluginErr |
| } |
| func (ec *ErrorRegisterCenterClient) LeaseRevoke(ctx context.Context, leaseID int64) error { |
| return noClientPluginErr |
| } |
| func (ec *ErrorRegisterCenterClient) Watch(ctx context.Context, opts ...registry.PluginOpOption) error { |
| return noClientPluginErr |
| } |
| func (ec *ErrorRegisterCenterClient) Close() { |
| ec.safeClose(ec.ready) |
| } |
| |
| func NewRegistry() mgr.PluginInstance { |
| return &ErrorRegisterCenterClient{ |
| ready: make(chan int), |
| } |
| } |