전체 글
-
List.of와 NullPointExecption언어/자바 2024. 3. 27. 08:14
자바에서 List.of를 사용해서 간편하게 List를 잘 만들어서 사용하고 있습니다. 모든 요소가 null 인 경우를 찾기 위해서 아래와 같은 방법을 사용하려고 했는데 public boolean isEmpty() { List checkList = List.of(title, requirements, preferred, stack, icon, status); return checkList.stream().noneMatch(Objects::nonNull); } 바로 NullPointException이 발생합니다. 잉? 자바 문서를 찾아보니 Null을 넣을 수 없다고 떡하니 적혀있습니다. (공식 문서) 대안을 찾아보니 Arrays.asList를 사용할 수 있을 것 같습니다. public boolean isEmp..
-
VARCHAR(255) 타입의 컬럼에 255 바이트 이상을 넣으려고 한다면?운영 중인 서비스/Coconut. 2024. 3. 25. 20:17
테스트를 적다가 발견한 이슈에 대해서 정리하려고 합니다. (테스트 코드 만세) 처음 데이터베이스 설계시에 데이터의 길이가 길어질 수 있음을 놓치고 VARCHAR(255)를 타입으로 적용하였습니다. 테스트에서 엣지 케이스를 고려하던 중, 255바이트를 초과하는 데이터를 삽입하려고 하면 에러가 발생합니다. MySQL에서 VARCHAR(255)타입이 설정된 컬럼에 1000바이트를 넣으면 255만큼만 들어갈까요? 하나도 안들어갈까요? 1. 에러의 발생 예시로 생각해본 데이터를 넣기에 255 바이트면 충분하다는 생각이 들어서 requirements의 타입을 VARCHAR(255)를 할당했습니다. 테스트를 작성하면서 엣지 케이스를 생각해보았는데, 경우에 따라서 해당 필드에는 충분히 긴 데이터가 들어갈 수도 있다는 ..
-
유저에게 권한 부여하기DB/mysql 2024. 3. 24. 02:40
더 안정적인 시스템을 운영하기 위해서 적절한 유저에게 적절한 권한을 부여하는 것이 중요합니다. 개인 작업을 하면 성가실 때가 많기 때문에 마스터 권한으로 작업하는 경우가 있지만 최소한의 권한을 가지고 작업하는 것을 습관으로 만들어버리면 어떨까 합니다. 이 글은 권한 설정을 가끔씩 하다보니 매번 찾는게 성가셔서 두고두고 참고하고자 적습니다. 1. 특정 데이터베이스 내에서 생성 권한 부여 # mysql GRANT CREATE ON .* TO 'user1'@'localhost'; FLUSH PRIVILEGES;
-
내가 보려고 만든 CodePipeline 구축 A to Z인프라/aws 2024. 3. 23. 22:21
1. 사전 설정하기 EC2 관련 사전 설정하기 (링크의 2. EC2 세팅하기 참고) 2. CodePipeline 생성하기 CodeBuild를 먼저 생성하지 않고 CodePipeline에서 생성하는 것이 포인트입니다. 2-1. 파이프라인 생성하기 적당한 이름으로 파이프라인을 만들어줍니다. 2-2. 소스 stage 생성하기 version2를 선택해서 원하는 레포의 브랜치와 연결해줍니다. 2-3. 빌드 stage 생성하기 만들어준 CodeBuild를 연결하지 않고 새로운 Build를 생성합니다. Create project를 누르면 Code Build 탭에서 만드는 것과 동일한 프로세스를 진행합니다. 차이점은 소스코드를 어디서 받는지 별도로 선택하지 않는다는 점입니다. ECR을 사용하기 때문에 privileg..
-
scp - secured copy protocol인프라/linux 2024. 3. 22. 19:19
aws에서 인프라를 구축하면서 ec2를 private subnet에 두고 외부에서 접근할 방법을 찾던 중 학습한 내용입니다. Bastion Host 역할을 하는 ec2에서 private subnet의 ec2에 ssh로 접근하는 방법을 사용하고 있습니다. 나름의 Microsevice를 구축하면서 새로운 EC2를 private subnet에서 사용해야하는 상황입니다. public ec2에서 private ec2로 ssh 통신을 하려고 하니 보안키가 필요한데, 보안키는 로컬 환경에 가지고 있습니다. 로컬에 있는 보안키를 어떻게 EC2로 옮길 수 있는지 찾아보니 scp 라는 프로토콜을 알게 되었습니다. $ scp -i /path/to/your/bastion-key.pem /path/to/your/ec2-key...
-
쓰기에 시간을 쓸 것인가? 읽기에 시간을 쓸 것인가?운영 중인 서비스/Coconut. 2024. 3. 21. 15:15
(소스코드: https://github.com/blog-example/-DB-Write-vs-Read) 이번에 서비스 배포하면서 전 회사에서 같이 일하던 선배 개발자분들에게 부탁해서 피드백을 받아보았습니다. 여러가지 피드백이 있었지만 이글에서는 게시글과 댓글의 ERD를 보고 주신 의견을 확인해보고자 글을 작성해봅니다. 글은 크게 5가지 항목으로 진행됩니다. 1. 실험의 배경 2. 테스트 세팅 3. 게시글 조회 성능 비교 4. 댓글 생성 성능 비교 5. 결론 1. 실험의 배경 1-1. 구현해야하는 요구사항 서비스는 기본적인 게시글과 댓글을 보여주는 UI를 가지고 있습니다. 구현해야하는 요구사항은 '게시글 목록에서 각 게시글에 달린 댓글의 숫자를 보여준다.' 였습니다. 이번 피드백에서 언급이 된 부분은 게시..
-
Patch Package로 의존성 이슈 해결하기운영 중인 서비스/Coconut. 2024. 3. 20. 02:32
서비스의 배포일정을 앞에 두고 사용 중인 라이브러리에서 이슈가 발견되어 빌드가 되지 않는 상황을 해결한 경험을 정리해봅니다. 프로젝트의 프론트엔드는 Next.js로 구현되어있고, 문제의 라이브러리는 'suneditor라는 텍스트 에이터 라이브러리입니다. 글은 크게 4가지 항목으로 진행됩니다. 1. 문제가 발생하는 라이브러리 2. 어떻게 대응할 것인가? 3. patch-package의 사용 4. 다른 옵션들 1. 문제 발생을 확인 게시글 작성 기능을 위해서 'suneditor' 라는 라이브러리를 사용하였습니다. 개발환경에서 실행하는 동안에는 문제가 없는 상태였으나, CI/CD 환경에서 빌드를 하는 도중 에러가 발생하는 상황입니다. 당황스러운 마음을 안고 검색을 통해서 라이브러리의 github에서 관련 정보..
-
[CodePipeline]Unable to access the artifact with Amazon S3 object key인프라/aws 2024. 3. 19. 04:11
Code Pipeline으로 CI/CD 구축하던 중 Deploy stage에서 발생한 에러입니다. 이 에러를 이해하려면 기본적으로 Code pipeline의 각 stage 간에 결과물을 s3를 사용해서 공유한다는 것을 기억해야합니다. [에러 해결을 위한 체크 리스트] 1. Build stage에서 s3에 artifacts를 남기고 있는가? 2. EC2에서 해당 버킷에 접근할 수 있는 권한을 가지고 있는가? 3. Code Deploy에서 소스코드를 받을 수 있는가? ( Code Deploy에서 소스코드를 사용해야한다면 ) 저 같은 경우에는 CodeBuild에서 ECR로 push 를 하는 상황이라 빌드의 결과물이 없기 때문에 s3에 artifacts를 업로드 하지않은 것이 이 에러 발생의 원인이었습니다. 문..