Skip to content

Instantly share code, notes, and snippets.

View ColinSullivan1's full-sized avatar

Colin Sullivan ColinSullivan1

View GitHub Profile
@ColinSullivan1
ColinSullivan1 / storebyname.go
Last active April 25, 2018 18:52
Test to get an interface using a "factory" name.
package main
import (
"fmt"
"reflect"
)
// Store is our fake Store
type Store interface {
FakeStoreInterfaceFunc()
@ColinSullivan1
ColinSullivan1 / Program.cs
Created May 18, 2018 18:36
C# Application, reconnect issue
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using NATS.Client;
namespace ConsoleApp1
{
public class Program
{
@ColinSullivan1
ColinSullivan1 / install-nats-client-sim.sh
Created October 5, 2018 18:43
install-nats-client-sim.sh
#!/bin/sh
wget https://dl.google.com/go/go1.11.1.linux-amd64.tar.gz
tar -zxvf go1.11.1.linux-amd64.tar.gz -C $HOME
export PATH=$HOME/go/bin:$PATH
export GOPATH=$HOME/gopath
export GOROOT=$HOME/go
echo "Getting nats-client-sim"
@ColinSullivan1
ColinSullivan1 / nats-server-log-rotate-win.md
Last active February 8, 2019 16:51
Rotating NATS server files on windows

Rotating log files in Windows

Here's a quick description of how to rotate log files on windows. In order to do so, your NATS server process must be running as a windows service. Here's an example setup and minimal config to setup log rotation.

The overall process is straightforward - when the server is running, change the name of the configuration file in your server config, and trigger a server reload. The server will close the old file and reopen

@ColinSullivan1
ColinSullivan1 / NATS2Inst.md
Last active July 16, 2019 18:54
NATS 2.0 Install

Setting up NATS 2.0 Security - DRAFT/WIP

Install the tools

nats-server

go get github.com/nats-io/nats-server

nsc

@ColinSullivan1
ColinSullivan1 / fwatch.go
Created May 21, 2019 16:09
Watches a directory, and periodically checks for changes in dir structure
package main
import (
"fmt"
"log"
"os"
"path/filepath"
"time"
"github.com/fsnotify/fsnotify"

Setting up NATS 2.0 Security

Install the tools

nats-server

go get github.com/nats-io/nats-server

nsc

@ColinSullivan1
ColinSullivan1 / mk_self_signed_test_cert.sh
Created May 8, 2020 17:38
Create self signed test certs (ca, client, server) with domain components "foo1" and "foo2"
#!/bin/sh
openssl genrsa -out ca.key 2048
openssl req -new -x509 -days 1826 -key ca.key -out ca.crt -subj "/C=US/ST=California/L=Los Angeles/O=NATS/OU=NATS/CN=localhost"
cp ca.key ca-key.pem
cat ca.key > ca.pem
cat ca.crt >> ca.pem
# create client certs
openssl genrsa -out client.key 2048
@ColinSullivan1
ColinSullivan1 / NGSJavaConnect.md
Created July 10, 2020 20:43
NGS Connect Java Code

Connecting to NGS with the Java NATS client version 2.6.8

In order to connect to NGS with the NATS java client, you need to include a java dependency for ED25519 support, set the connection to secure, and enable the NATS credentials.

        Options o = new Options.Builder().
	         authHandler(server("nats://connect.ngs.global:4222").
                 Nats.credentials("/users/colinsullivan/.nkeys/creds/synadia/First/First.creds"))
 secure().