페이지

2021년 7월 25일 일요일

Spring RSocket Validation / Error Handling

* RSocket treats app exceptions as an ApplicationErrorException(string message)

* Raising error signal will end response

* Prefer

    - defaultIfEmpty

    - switchIfEmpty

    - onErrorReturn

* Send exception/error details as Item response

* @MessageExceptionHandler 

2021년 7월 23일 금요일

Spring RSocket API Model

RSocket Request : Response Input Type Output Tpye
Request & Response 1:1 Mono<T> Mono<R>
Fire & Forget       1:0 Mono<T> Mono<Void>
Request Stream 1:N Mono<T> Flux<R>
Request Channel M:N Flux<T> Flux<R>


Routing

@MessageMapping("create.user")
public Mono<User> createUser(Mono<User> usermono){
    return this.userService.create(usermono);
}

@MessageMapping("update,user")
public Mono<User> updateUser(Mono<User> usermono){
    return this.userService.update(usermono);
}

RSocketRequester W/O Data

rSocketRequester.route("product.all")
                 //.data()
                 .retrieveFlux(Product.class);


2021년 7월 17일 토요일

RSocket Response - Streaming vs Single List

  • Streaming T
    • Size - Potentially large /unknown
      • Pagination
      • Uber driver location updates
      • Online home-delivery update
    • Receiving side might take too much time to process
      • File upload
    • More effcient than multiple Request & Response calls

  • Single List<T>
    • Size is small & Data already in hand!
    • More efficient than streaming response

RSocket -> Peer-to-Peer

 




SocketAcceptor



2021년 7월 16일 금요일

RSocket API Model


RSocket Request : Response HTTP
Request & Response 1:1 YES
Fire & Forget 1:0 NO
Request Stream 1:N NO
Request Channel M:N NO

RSocket

- RSocket is a binary protocol for client/server application - peer-to-peer messaging - Supports Reactive-Streams * Aync * Non-blocking * BackPressure support - Supports * TCP * WebSockets * Aeron(UDP) - Developed by Netflix - Supports other languages like js, go, py, kotlin etc

2021년 7월 2일 금요일

Spring Boot Annotaions

@RunWith(SpringRunner.class)	Run test with Spring Context.
@SpringBootTest Search for Spring Boot Application for configuration.
@TestConfiguration Specify a Spring configuration for your test.
@MockBean Injects Mockito Mock
@SpyBean Injects Mockito Spy
@JsonTest Creates a Jackson or Gson object mapper via Spring Boot.
@WebMvcTest Used to test web context without a full http server.
@DataJpaTest Used to test data layer with embedded database.
@TestPropertySource Configure the property sources for the test.
@DirtiesContext Resets the Spring Context after the test(expensive to do).
@WebAppConfiguration Indicates Spring should use a Web Application context.
@TestExecutionListeners Allows you to specify listeners for testing events.
@Transactional Run test in transaction, rollback when complete by default.
@BeforeTranasaction Action to run before starting a transaction.
@AfterTransaction Action to run after a transaction.
@Commit Specifies the transaction should be committed after the test.
@Rollback Transaction should be rolled back after test.(Default action)
@Sql Specify SQL scripts to run before.
@SqlConfig Define meta data for SQL scripts.
@SqlGroup Group fo @Sql annotations.
@Repeat Repeat test x number of times.
@Timed Similar to JUnit's timeout, but will wait for test to complete, unlike JUnit.
@IfProfileValue Indicates test is enabled for a specific testing environment.
@ProfileValueSourceConfiguration Specify a profile value source.

JUnit 4 Annotations

@Test		Identifies a method as a test method.
@Before Executed before each test. It is used to prepare the test environment (e.g. read input data, initialize the class).
@After Executed after test. It is used to cleanup the test environment. It can also save memory by cleaning up expensive memory structures.
@BeforeClass Executed once, before the start of all tests. Methods marked with this annotaion need to be defined as static to work with JUnit.
@AfterClass Executed once, after all tests have been finished. Methods annotated with this annotation need to be defined as static to work with JUnit.
@Ignore Marks that the test should be disabled.
@Test(expected = Fails if the method does not throw the named exception. Exception.class)
@Test(timeout = 10) Fails if the method takes longer than 100 millseconds.

2021년 4월 2일 금요일

Types of Services

 Cluster IP => Set up an easy-to-remember URL to access a pod. 

                   Only exposes pods in the cluster


Node Port => Makes a pod accessible from outside the cluster.

                   Usually only used for dev purposes


Load Balancer =>  Makes a pod accessible from outside the cluster. 

                         This is the right way to expose a pod to the outside world


External Name => Redirects an in-cluster request to a CNAME url...


_______________________________________________________________________________________


Load Balancer Service =>  Tells Kubernetes to reach out to its provider

                                   and provision a load balancer. 

                                  Gets traffic in to a single pod


Ingress or Ingress Controller => 

A pod with a set of routing rules to distribute traffic to other services

2021년 3월 27일 토요일

Kubernetes Config Files

 1. Thells Kubernetes about the different Deployments, Pods, and Services 
(referred to as 'Objects') that we want to create

 


2. Written in YAML syntax


3. Always store these files with our project source code - they are documentation!


4. We can create Objects without config files - do not do this. Config files 

provide a precise definition of what your cluster is running.


 Install MiniKube (https://kubernetes.io/docs/tasks/tools/install-minikube/)

minikube start


kubectl version


kubectl get all


kubectl apply -f first-pod.yaml


kubectl get all


minikube ip


kubectl describe pod webapp


kubectl exec webapp ls


kubectl -it exec webapp sh

wget http://localhost:80


cat index.html








kubernetes

 Kubernetes Cluster       => A collections of nodes + a master to manage them

 Node                        => A virtual machine that will run our containers

Pod                           => More or less a running container.

                                     Technically, a pod can run multiple containers

                                     (we won't do this)

Deployment                => Monitors a set of pods, make sure they are running

                                    and restarts them if they crash

Service                      => Provides an easy-to-remember URL to access 

                                    a running container


 



2021년 3월 26일 금요일

node js building docker

 FROM                  node:alpine       => Specify base image

 WORKDIR             /app                => Set the working directory to '/app' in the                                                                  container. All following commands will be 

                                                      issued relative to this dir

 COPY                   package.json ./   => Copy over only the package.json file

 RUN                    npm install        => Install all dependencies

 COPY                   ./ ./                 => Copy over all of our remaining source code

 CMD                    ["npm", "start"]  => Set the command to run when the container

                                                      starts up


Dockerfile


FROM node:alpine


WORKDIR /app

COPY package.json ./

RUN npm install

COPY ./ ./


CMD ["npm", "start"]




.dockerignore


node_modules


docker build .


Successfully built eb521ea6b7e6


docker run eb521ea6b7e6

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


docker build -t abcdefg/efgh .            => Build an image based on the dockerfile in the 

                                                        current directory. Tag it as 'abcdefg/efgh'

docker run [image id or image tag]     => Create and start a container based on the

                                                        provided image id or tag

docker run -it [image id or image tag] [cmd] => Create and start container, but also

                                                                override the default command

docker ps                                    => Print out information about all of the 

                                                      running containers

docker exec -it [container id] [cmd]    => Execute the given command in a running 

                                                      container

docker logs [container id]                => Print out logs from the given container