Message config for whatsapp multi language flow#15
Message config for whatsapp multi language flow#15vinaysingri wants to merge 3 commits intoprojectstepone:masterfrom
Conversation
|
|
||
| public interface MessageConfigStore { | ||
|
|
||
| Optional<MessageConfig> create(MessageConfig messageConfig); |
There was a problem hiding this comment.
should create return optional ? if it fails, it should throw the exception right rather than fail internally ?
| String messageId; | ||
|
|
||
| @NotNull | ||
| JsonNode messageBody; |
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| @Builder | ||
| public class StoredMessageConfig { |
There was a problem hiding this comment.
can we merge this with MessageConfig ?
| public MessageConfigStoreCommand(LookupDao<StoredMessageConfig> messageLookupDao) { | ||
| this.messageLookupDao = messageLookupDao; | ||
| messageConfigCache = Caffeine.newBuilder() | ||
| .maximumSize(1_000) |
There was a problem hiding this comment.
Just a digit seperator notion that I took from other classes. For grouping digits for better readability
| messageConfigCache = Caffeine.newBuilder() | ||
| .maximumSize(1_000) | ||
| .expireAfterWrite(300, TimeUnit.SECONDS) | ||
| .refreshAfterWrite(60, TimeUnit.SECONDS) |
There was a problem hiding this comment.
whats expire after write ? also refresh can be slower and 15 mins should be fine IMO
There was a problem hiding this comment.
expire after write is basically looks at last write time and expires the entry after specified time, we can increase it and sure I will increase the refresh time
| @Override | ||
| public Optional<MessageConfig> get(String messageConfigId) { | ||
| try { | ||
| return messageConfigCache.get(messageConfigId); |
There was a problem hiding this comment.
how are we pre populating data ? should we fall back to DB if cache miss occurs ? because ideally we don't expect to query for a msg id which doesn't exist. so either msg is present in cache or in DB.
or are we pre populating the DB somehow ? in that case how will new writes get cached ?
There was a problem hiding this comment.
We have this method called getFromDb which is hooked into caffine while building the cache, so any cache miss will lead to a DB call.
|
lets also add comments for class responsibilites |
| throw new StatesmanError("No message config found", ResponseCode.NO_PROVIDER_FOUND); | ||
| } | ||
|
|
||
| MessageConfig storeOutput = optionalMessageConfig.get(); |
There was a problem hiding this comment.
can we add a comment of the json structure ? will help whoever will read this code in future
No description provided.