% Fix for: https://tex.stackexchange.com/a/315027/43228
\RequirePackage{luatex85}
\documentclass[border=10pt,17pt]{standalone}

\usepackage{cfr-lm}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,snakes}
\usetikzlibrary{shapes.multipart}

\begin{document}

%% sans-serif fonts, large by default, and bold too
\sffamily
\sbweight
\bfseries
\large

\begin{tikzpicture}[>=stealth',auto,rounded corners]

  \input{common.tex}

  %% \draw [help lines] (-10,0) grid (10,20);

  \node (flegend) at (8,18) {\textt{number\_sync\_standby = 1}} ;

  \node  (a)   at (0,18)   [primary]
         {\textbf{\normalsize Node A}
           \nodepart{second}
           \textbf{\Large Primary}
           \nodepart[text=stxt]{third}
		   \texttt{replication quorum = true} \\
		   \texttt{candidate priority = 50}
         };

  \node  (b)   at (0,12)  [standby]
         {\textbf{\normalsize Node B}
           \nodepart{second}
           \textbf{\Large Secondary}
           \nodepart{third}
		   \texttt{replication quorum = true} \\
		   \texttt{candidate priority = 50}
         };

  \node  (c)   at (0,6)   [standby]
         {\textbf{\normalsize Node C}
           \nodepart{second}
           \textbf{\Large Secondary}
           \nodepart{third}
		   \texttt{replication quorum = true} \\
		   \texttt{candidate priority = 50}
         };

  \node  (app) at (-8,12)  [app]        {\textbf{\Large Application}};
  \node  (m)   at (8,12)   [monitor]    {\textbf{\Large Monitor}};

  \path (app) edge [sql,out=90,in=180]  node[near start] {SQL} (a.west)
              edge [sqlf] (b)
              edge [sqlf,out=-90,in=180] node[near start,above]  {SQL (fallback)} (c.west)

        (a.south east) edge [sr,out=0,in=35]  node[left,near start]   {Streaming Replication}   (b.north east)
        (a.south east) edge [sr,out=0,in=35] (c.north east)

        (m)   edge [hc,out=90,in=0]  (a.east)
              edge [hc,out=180,in=0] (b.east)
              edge [hc,out=-90,in=0] node[below,near end] {Health checks} (c.east);
\end{tikzpicture}

\end{document}
