public void Run(object o) { while (true) { if (!_nodeInfo.HaveAcessRight) { break; } if (!PureCat.IsInitialized()) { Thread.Sleep(5000); continue; } PureCat.DoTransaction("System", "Status", () => { _nodeInfo.Refresh(); PureCat.LogHeartbeat("Heartbeat", AppEnv.IP, PureCatConstants.SUCCESS, XmlHelper.XmlSerialize(_nodeInfo, Encoding.UTF8)); PureCat.LogEvent("System", $"Cat.Version : {PureCat.Version}", PureCatConstants.SUCCESS, PureCat.Version); }); Thread.Sleep(60000); } }
static CatContext DoTest() { var times = _rand.Next(1000); Thread.Sleep(times); PureCat.LogEvent("Do", nameof(DoTest), "0", $"sleep {times}"); return(PureCat.LogRemoteCallClient("callAdd")); }
static void Main(string[] args) { PureCat.Initialize(); while (true) { var a = DateTime.Now.Second; Console.WriteLine(DateTime.Now); var context = PureCat.DoTransaction("Do", nameof(DoTest), DoTest); var b = DateTime.Now.Second; PureCat.DoTransaction("Do", nameof(Add), () => Add(a, b, context)); } }
internal Context GetContext() { if (PureCat.IsInitialized()) { Context ctx = _mContext.Value; if (ctx != null) { return ctx; } } return null; }
public ITransaction AddChild(IMessage message) { if (_mChildren == null) { _mChildren = new List <IMessage>(); } if (message != null) { _mChildren.Add(message); } else { PureCat.LogError(new Exception("null child message")); } return(this); }
public DefaultForkedTransaction(string type, string name, IMessageManager messageManager) : base(type, name, messageManager) { Standalone = false; IMessageTree tree = messageManager.ThreadLocalMessageTree; if (tree != null) { _rootMessageId = tree.RootMessageId; _parentMessageId = tree.MessageId; // Detach parent transaction and this forked transaction, by calling linkAsRunAway(), at this earliest moment, // so that thread synchronization is not needed at all between them in the future. _forkedMessageId = PureCat.CreateMessageId(); } }
static void Add(int a, int b, CatContext context = null) { PureCat.LogRemoteCallServer(context); PureCat.LogEvent("Do", nameof(Add), "0", $"{a} + {b} = {a + b}"); }