This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# iam_role | |
resource "aws_iam_role" "iam_role" { | |
name = "iam-role" | |
assume_role_policy = templatefile("${path.module}/templates/lambda-base-policy.tpl", {}) | |
} | |
#content of lambda-base-policy.tpl | |
{ | |
"Version": "2012-10-17", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server: | |
port: 8765 | |
spring: | |
application.name: morannon | |
eureka: | |
client: | |
registerWithEureka: true | |
fetchRegistry: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X POST http://localhost:8080/messages -H "content-type:application/json" -d '{"text": "hello, world!", "room": "developers"}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.createCollection("messages", { capped: true, size: 5000000, max: 10000 }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Repository | |
interface MessageRepository : ReactiveMongoRepository<Message, String> { | |
@Tailable | |
fun findWithTailableCursorByRoom(room: String): Flux<Message> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
class MessageService(val messageRepository: MessageRepository) { | |
fun findWithTailableCursorByRoom(room: String): Flux<MessageView> { | |
return this.messageRepository.findWithTailableCursorByRoom(room) | |
.map { it -> MessageView(it.text, "anonymous", LocalDateTime.now()) } | |
} | |
fun newMessage(messageBody: MessageBody) { | |
this.messageRepository.save(Message(null, messageBody.text, messageBody.room)).subscribe() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping("/messages") | |
class MessageController(val messageService: MessageService) { | |
@GetMapping(produces = [(MediaType.TEXT_EVENT_STREAM_VALUE)]) | |
fun allMessages(@RequestParam room: String): Flux<MessageView> { | |
return this.messageService.findWithTailableCursorByRoom(room) | |
} | |
@PostMapping |