public void SyncRemote(ServiceNameDiscoveryService.ServiceNameDiscoveryServiceClient serviceClient)
        {
            if (_unRegisterOpNames.Count > 0)
            {
                var serviceNameCollection = new ServiceNameCollection();
                foreach (var opName in _unRegisterOpNames)
                {
                    var serviceName = new ServiceNameElement();
                    serviceName.ApplicationId = opName.Key.ApplicationId;
                    serviceName.ServiceName   = opName.Key.OperationName;
                    serviceName.SrcSpanType   = opName.Key.SpanType;
                    serviceNameCollection.Elements.Add(serviceName);
                }

                var mapping = serviceClient.discovery(serviceNameCollection);

                foreach (var item in mapping.Elements)
                {
                    var element = item.Element;
                    var key     = new OperationNameKey(element.ApplicationId, element.ServiceName,
                                                       SpanType.Entry == element.SrcSpanType, SpanType.Exit == element.SrcSpanType);
                    _unRegisterOpNames.TryRemove(key, out _);
                    _operationNameDic.TryAdd(key, item.ServiceId);
                }
            }
        }
        private PossibleFound internalFind(int applicationId, string operationName, bool isEntry, bool isExit,
                                           bool registerWhenNotFound)
        {
            if (string.IsNullOrEmpty(operationName))
            {
                return(NotFound.Instance);
            }

            var operationNameKey = new OperationNameKey(applicationId, operationName, isEntry, isExit);

            if (_operationNameDic.TryGetValue(operationNameKey, out var id))
            {
                return(new Found(id));
            }
            else
            {
                if (registerWhenNotFound && _operationNameDic.Count + _unRegisterOpNames.Count <
                    DictionaryConfig.OperationNameBufferSize)
                {
                    _unRegisterOpNames.TryAdd(operationNameKey, null);
                }

                return(NotFound.Instance);
            }
        }