コード例 #1
0
        public void SendData(List <Activity> activities)
        {
            var copy = new List <Activity>(activities);

            if (copy.Any() && _dataSender.Send(copy))
            {
                _activityStack.Remove(copy);
            }
        }
コード例 #2
0
        private void DoUpdateChangeKey(RedisClient client, string setId, object keyByte, byte[] values, bool isHash, byte[] buffer)
        {
            string key = isHash
                ? Encoding.UTF8.GetString((byte[])keyByte)
                : keyByte.ToString();
            dynamic entity = null;

            try
            {
                entity = CovertEntityObject(key, values);
                CacheType cacheType = CacheType.None;
                if (entity != null)
                {
                    SchemaTable schema;
                    Type        entityType = entity.GetType();
                    if (!EntitySchemaSet.TryGet(entityType, out schema))
                    {
                        EntitySchemaSet.InitSchema(entityType);
                    }
                    if (schema != null || EntitySchemaSet.TryGet(entityType, out schema))
                    {
                        cacheType = schema.CacheType;
                    }
                    if (cacheType != CacheType.None)
                    {
                        string redisKey = cacheType == CacheType.Dictionary
                            ? key.Split('|')[0]
                            : key.Split('_')[0];

                        using (IDataSender sender = DataSyncManager.GetRedisSender(redisKey))
                        {
                            sender.Send(entity);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("ChangeKey:{0} error:{1}", key, ex);
            }
            if (isHash)
            {
                client.HDel(setId, (byte[])keyByte);
            }
            else
            {
                client.ZRem(setId, buffer);
            }
            if (entity != null)
            {
                Type   type      = entity.GetType();
                string entityKey = string.Format("{0},{1}", key, type.Assembly.GetName().Name);
                client.HSet("__GLOBAL_SQL_CHANGE_KEYS_NEW", Encoding.UTF8.GetBytes(entityKey), new byte[] { 1 });
            }
        }
コード例 #3
0
        private void DoSend(uint invokeId, uint methodId, byte[] forwardKey, object[] args)
        {
            // todo to avoid MemoryStream and BinaryWriter allocations every time data comes
            // todo RPCBase.Server could change to use ThreadLocal<T>
            // todo RPCBase.Clent could use singleton directly
            var buffer       = new MemoryStream(32);
            var bufferWriter = new BinaryWriter(buffer);

            var uuidBytes = dataSender.Uuid.ToByteArray();

            bufferWriter.Write(uuidBytes.Length);
            bufferWriter.Write(uuidBytes);
            bufferWriter.Write(invokeId);
            methodSerializer.Write(methodId, args, bufferWriter);

            dataSender.Send(buffer.GetBuffer(), forwardKey, routingRule);
            //dataSender.Send(buffer.GetBuffer(), serviceMetaInfo.GetDelegateRoutingKey(forwardKey), serviceMetaInfo.GetDelegateExchangeName());
        }