Derik Badman's Journal

Content Tagged "Nodejs"

This shows only partial entries if specific parts of the entry were tagged rather than the whole entry.

2019-09-04 08:05

At work I've been spending a long time converting the chat app I work on from a single server deployment using a lot of in memory storage, to a load balanced multi-server deployment that cannot completely use in memory storage. We are using Socket.io for handling the websockets with the fallback to xhr polling for those with older browsers (like many of our customers unfortunately), and I've been implementing an adaptor that uses Redis pubsub to handle communication between servers. Because the pubsub calls are asynchronous it's forced me to use a lot more asynchronous functions in the code. So I've been getting a crash course in Promises and async/await functions, which I had previously read about but not used much. Oddly, the hardest part at times was figuring out how to write decent unit tests for those functions. I still have a couple use cases where I just can't seem to get the unit tests to coverage certain situations (particularly the catch blocks). I do really enjoy working in node though, the freedom to not think about browser compatibility allows me to learn a lot of javascript that I have not otherwise been able to implement, such as Classes. I've been working on this issue (the load balancing) for more than a week now, I think I might have literally changed every file in the repository. Client testing is brutal too. Normal chat testing can be a total pain as I tend to have to open multiple tabs for operators and patrons in the chat, as well as a utility I have for monitoring logs. But with multiple servers, not yet load balanced, I also need to think about which connections are going to which servers, so I can make sure the cross-server communication is working. I am going to be so glad to be off all next week.

[View full entry]