You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -76,6 +76,9 @@ Olric is in early stages of development. The package API and client protocol may
76
76
*[Serialization](#serialization)
77
77
*[Golang Client](#golang-client)
78
78
*[Configuration](#configuration)
79
+
*[Embedded Member Mode](#embedded-member-mode)
80
+
*[Client-Server Mode](#client-server-mode)
81
+
*[Network Configuration](#network-configuration)
79
82
*[Service discovery](#service-discovery)
80
83
*[Architecture](#architecture)
81
84
*[Overview](#overview)
@@ -807,152 +810,42 @@ configuration parameters, see [Olric documentation on GoDoc.org](https://godoc.o
807
810
808
811
## Configuration
809
812
810
-
[memberlist configuration](https://godoc.org/github.com/hashicorp/memberlist#Config) can be tricky and the default configuration set should be tuned for your environment. A detailed deployment and configuration guide will be prepared before stable release.
813
+
You should feel free to ask any questions about configuration and integration. Please see [Support](#support) section.
811
814
812
-
Please take a look at [Config section at godoc.org](https://godoc.org/github.com/buraksezer/olric#Config)
815
+
### Embedded-Member Mode
813
816
814
-
It's generally good to use `config.New` function to get the default configuration. It takes `local`, `lan` and `wan` parameters.
815
-
Please see the [documentation](https://godoc.org/github.com/buraksezer/olric/config#New) to get more information.
816
-
817
-
Here is a sample configuration for a cluster with two hosts:
817
+
Olric provides a function to generate default configuration to use in embedded-member mode:
log.Fatalf("Failed to create Olric object: %v", err)
873
-
}
874
-
gofunc() {
875
-
// Call Start at background. It's a blocker call.
876
-
err = db1.Start()
877
-
if err != nil {
878
-
log.Fatalf("Failed to call Start: %v", err)
879
-
}
880
-
}()
881
-
882
-
c2:=config2()
883
-
// This creates a single-node Olric cluster. It's good enough for experimenting.
884
-
db2, err:= olric.New(c2)
885
-
if err != nil {
886
-
log.Fatalf("Failed to create Olric object: %v", err)
887
-
}
820
+
import"github.com/buraksezer/olric/config"
821
+
...
822
+
c:= config.New("local")
823
+
```
888
824
889
-
gofunc() {
890
-
// Call Start at background. It's a blocker call.
891
-
err = db2.Start()
892
-
if err != nil {
893
-
log.Fatalf("Failed to call Start: %v", err)
894
-
}
895
-
}()
825
+
The `New` function takes a parameter called `env`. It denotes the network environment and consumed by [hashicorp/memberlist](https://github.com/hashicorp/memberlist).
826
+
Default configuration is good enough for distributed caching scenario. In order to see all configuration parameters, please take a look at [this](https://godoc.org/github.com/buraksezer/olric/config).
896
827
897
-
// You can use `config.Started` callback function to get notified about a server start
898
-
// for the sake of simplicity, we just call time.After for some time.
899
-
fmt.Println("Awaiting for background goroutines")
900
-
<-time.After(time.Second)
828
+
See [Sample Code](#sample-code) section for an introduction.
fmt.Printf("Value for string-key: %v, reflect.TypeOf: %s\n", stringValue, reflect.TypeOf(stringValue))
832
+
Olric provides **olricd** to implement client-server mode. olricd gets a YAML file for the configuration. The most basic functionality of olricd is that
833
+
translating YAML configuration into Olric's configuration struct. A sample `olricd.yaml` file is being provided [here](https://github.com/buraksezer/olric/blob/master/cmd/olricd/olricd.yaml).
919
834
920
-
err = dm.Put("uint64-key", uint64(1988))
921
-
if err != nil {
922
-
log.Fatalf("Failed to call Put: %v", err)
923
-
}
924
-
uint64Value, err:= dm.Get("uint64-key")
925
-
if err != nil {
926
-
log.Fatalf("Failed to call Get: %v", err)
927
-
}
928
-
fmt.Printf("Value for uint64-key: %v, reflect.TypeOf: %s\n", uint64Value, reflect.TypeOf(uint64Value))
835
+
### Network Configuration
929
836
930
-
err = dm.Put("nil-key", nil)
931
-
if err != nil {
932
-
log.Fatalf("Failed to call Put: %v", err)
933
-
}
934
-
nilValue, err:= dm.Get("nil-key")
935
-
if err != nil {
936
-
log.Fatalf("Failed to call Get: %v", err)
937
-
}
938
-
fmt.Printf("Value for nil-key: %v\n", nilValue)
939
-
fmt.Println("##")
837
+
In an Olric instance, there are two different TCP servers. One for Olric, and the other one is for memberlist. `BindAddr` is very
838
+
critical to deploy a healthy Olric node. There are different scenarios:
940
839
941
-
// Don't forget the call Shutdown when you want to leave the cluster.
* You can freely set a domain name or IP address as `BindAddr` for both Olric and memberlist. Olric will resolve and use it to bind.
841
+
* You can freely set `localhost`, `127.0.0.1` or `::1` as `BindAddr` in development environment for both Olric and memberlist.
842
+
* You can freely set `0.0.0.0` as `BindAddr` for both Olric and memberlist. Olric will pick an IP address, if there is any.
843
+
* If you don't set `BindAddr`, hostname will be used, and it will be resolved to get a valid IP address.
844
+
* You can set a network interface by using `Config.Interface` and `Config.MemberlistInterface` fields. Olric will find an appropriate IP address for the given interfaces, if there is any.
845
+
* You can set both `BindAddr` and interface parameters. In this case Olric will ensure that `BindAddr` is available on the given interface.
947
846
948
-
// Don't forget the call Shutdown when you want to leave the cluster.
You should know that Olric needs a single and stable IP address to function properly. If you don't know the IP address of the host at the deployment time,
848
+
you can set `BindAddr` as `0.0.0.0`. Olric will very likely to find an IP address for you.
956
849
957
850
### Service Discovery
958
851
@@ -1218,7 +1111,6 @@ func main() {
1218
1111
1219
1112
<-ctx.Done()
1220
1113
1221
-
// Put 10 items into the DMap object.
1222
1114
dm, err:= db.NewDMap("bucket-of-arbitrary-items")
1223
1115
if err != nil {
1224
1116
log.Fatalf("olric.NewDMap returned an error: %v", err)
0 commit comments