Skip to content

Commit

Permalink
chore: switch docs and examples to use pre-built configurations (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
nand4011 authored Sep 22, 2023
1 parent 14c3765 commit 3ff3b2f
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 44 deletions.
8 changes: 1 addition & 7 deletions examples/basic.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,7 @@ end
Logger.info("Hello world")
Logger.info("Hello logging world!")

config = %Momento.Config.Configuration{
transport_strategy: %Momento.Config.Transport.TransportStrategy{
grpc_config: %Momento.Config.Transport.GrpcConfiguration{
deadline_millis: 5000
}
}
}
config = Momento.Configurations.Laptop.latest()

credential_provider = Momento.Auth.CredentialProvider.from_env_var!("MOMENTO_AUTH_TOKEN")
cache_client = Momento.CacheClient.create!(config, credential_provider, 60.0)
Expand Down
8 changes: 1 addition & 7 deletions examples/doc_examples.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ defmodule Examples.DocExamples do

@spec example_API_InstantiateCacheClient() :: Momento.CacheClient.t()
def example_API_InstantiateCacheClient() do
config = %Momento.Config.Configuration{
transport_strategy: %Momento.Config.Transport.TransportStrategy{
grpc_config: %Momento.Config.Transport.GrpcConfiguration{
deadline_millis: 5000
}
}
}
config = Momento.Configurations.Laptop.latest()

credential_provider = Momento.Auth.CredentialProvider.from_env_var!("MOMENTO_AUTH_TOKEN")
default_ttl_seconds = 60.0
Expand Down
9 changes: 1 addition & 8 deletions examples/doc_examples/cheat_sheet.exs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
alias Momento.CacheClient

config = %Momento.Config.Configuration{
transport_strategy: %Momento.Config.Transport.TransportStrategy{
grpc_config: %Momento.Config.Transport.GrpcConfiguration{
deadline_millis: 5000
}
}
}

config = Momento.Configurations.Laptop.latest()
credential_provider = Momento.Auth.CredentialProvider.from_env_var!("MOMENTO_AUTH_TOKEN")
default_ttl_seconds = 60.0
client = CacheClient.create!(config, credential_provider, default_ttl_seconds)
9 changes: 1 addition & 8 deletions examples/doc_examples/readme_example.exs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
alias Momento.CacheClient

config = %Momento.Config.Configuration{
transport_strategy: %Momento.Config.Transport.TransportStrategy{
grpc_config: %Momento.Config.Transport.GrpcConfiguration{
deadline_millis: 5000
}
}
}

config = Momento.Configurations.Laptop.latest()
credential_provider = Momento.Auth.CredentialProvider.from_env_var!("MOMENTO_AUTH_TOKEN")
default_ttl_seconds = 60.0
client = CacheClient.create!(config, credential_provider, default_ttl_seconds)
Expand Down
8 changes: 1 addition & 7 deletions examples/sorted_set.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ alias Momento.CacheClient

IO.puts("==Sorted Set Example==")

config = %Momento.Config.Configuration{
transport_strategy: %Momento.Config.Transport.TransportStrategy{
grpc_config: %Momento.Config.Transport.GrpcConfiguration{
deadline_millis: 5000
}
}
}
config = Momento.Configurations.Laptop.latest()

credential_provider = Momento.Auth.CredentialProvider.from_env_var!("MOMENTO_AUTH_TOKEN")
client = CacheClient.create!(config, credential_provider, 60.0)
Expand Down
8 changes: 1 addition & 7 deletions src/lib/momento/cache_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ defmodule Momento.CacheClient do
Client to perform operations against a Momento cache.
A client is created by supplying a configuration, a credential provider, and a default time-to-live:
config = %Momento.Config.Configuration{
transport_strategy: %Momento.Config.Transport.TransportStrategy{
grpc_config: %Momento.Config.Transport.GrpcConfiguration{
deadline_millis: 5000
}
}
}
config = Momento.Configurations.Laptop.latest()
credential_provider = Momento.Auth.CredentialProvider.from_env_var!("MOMENTO_AUTH_TOKEN")
default_ttl_seconds = 60.0
Expand Down

0 comments on commit 3ff3b2f

Please sign in to comment.