-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add Kotlin docs #648
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
--- | ||
sidebar_position: 1 | ||
sidebar_label: Cheat Sheet | ||
title: Cheat Sheet for Kotlin | ||
description: Get started really quickly coding using Kotlin with Momento Cache | ||
--- | ||
|
||
import { SdkExampleCodeBlock } from "@site/src/components/SdkExampleCodeBlock"; | ||
// This import is necessary even though it looks like it's un-used; The inject-example-code-snippet | ||
// plugin will transform instances of SdkExampleCodeBlock to SdkExampleCodeBlockImpl | ||
import { SdkExampleCodeBlockImpl } from "@site/src/components/SdkExampleCodeBlockImpl"; | ||
|
||
# Cheat Sheet for Kotlin with Momento Cache | ||
|
||
If you need to get going quickly with Kotlin and Momento Cache, this page contains the basic API calls you'll need. [Check the Kotlin SDK examples](https://github.com/momentohq/client-sdk-kotlin/tree/main/examples) for complete, working examples including build configuration files. | ||
|
||
## Install the Momento client library | ||
|
||
Install the client library in an existing Kotlin project: | ||
|
||
### Gradle | ||
|
||
```kotlin | ||
implementation("software.momento.kotlin:sdk:0.1.3") | ||
``` | ||
|
||
### Maven | ||
|
||
```xml | ||
<dependency> | ||
<groupId>software.momento.kotlin</groupId> | ||
<artifactId>sdk</artifactId> | ||
<version>0.1.3</version> | ||
</dependency> | ||
``` | ||
|
||
## Set up your auth token | ||
|
||
You'll need a Momento API key to authenticate with Momento. You can get one from the [Momento Web Console](https://console.gomomento.com/caches). | ||
Once you have your token, store it in an environment variable so that the Momento client can consume it: | ||
|
||
``` | ||
export MOMENTO_API_KEY=<your Momento API key here> | ||
``` | ||
|
||
## Import libraries and connect to return a CacheClient object | ||
This code sets up the main function, the necessary imports, and the CacheClient instantiation that each of the other functions will need to call. | ||
|
||
<SdkExampleCodeBlock language={'kotlin'} file={'CheatSheet.kt'} /> | ||
|
||
## Create a new cache in Momento Cache | ||
Use this function to create a new cache in your account. | ||
|
||
<SdkExampleCodeBlock language={'kotlin'} snippetId={'API_CreateCache'} /> | ||
|
||
|
||
## List the names of existing caches in your account | ||
A simple list of the names of caches for the account. | ||
|
||
<SdkExampleCodeBlock language={'kotlin'} snippetId={'API_ListCaches'} /> | ||
|
||
## Write an item to a cache | ||
A simple example of doing a set operation. In the client.set call, the TTL it optional. If you did pass it in, this would override the default TTL value set with the client connection object. | ||
|
||
<SdkExampleCodeBlock language={'kotlin'} snippetId={'API_Set'} /> | ||
|
||
## Read an item from a cache | ||
This is an example of a simple read operation to get an item from a cache. | ||
|
||
<SdkExampleCodeBlock language={'kotlin'} snippetId={'API_Get'} /> | ||
|
||
## Running the code | ||
|
||
You can find complete, working examples in the [Kotlin SDK github repo examples directory](https://github.com/momentohq/client-sdk-kotlin/tree/main/examples). | ||
|
||
:::info | ||
Beyond these basic API calls check out the [API reference page](/cache/develop/api-reference/index.mdx) for more information on the full assortment of Momento API calls. | ||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
sidebar_position: 6 | ||
title: Momento Kotlin SDK | ||
pagination_prev: null | ||
sidebar_label: Kotlin | ||
description: Information about the Momento Kotlin SDK | ||
--- | ||
|
||
# Momento Kotlin SDK | ||
|
||
The Momento Kotlin SDK for Android and JVM is available via Maven Central: [`software.momento.kotlin:sdk`](https://central.sonatype.com/artifact/software.momento.kotlin/sdk). | ||
|
||
|
||
The source code can be found on GitHub: [momentohq/client-sdk-kotlin](https://github.com/momentohq/client-sdk-kotlin). | ||
|
||
## Requirements | ||
|
||
- A Momento API Key is required; you can get one from the [Momento Web Console](https://console.gomomento.com/). | ||
- At least the Java 11 run time installed, or Android 23+. | ||
- mvn or gradle for downloading the sdk. | ||
|
||
## Resources | ||
|
||
- [Kotlin SDK Cheat Sheet](./cheat-sheet.mdx) | ||
- [Kotlin SDK Examples](https://github.com/momentohq/client-sdk-kotlin/blob/main/examples/README.md): working example projects that illustrate how to use the Kotlin SDK | ||
- COMING SOON: Observability: Logging and Client-side Metrics with the Kotlin SDK | ||
- COMING SOON: Taking your code to prod: Configuration and Error handling in the Kotlin SDK | ||
|
||
## Integrations | ||
|
||
COMING SOON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
sidebar_position: 6 | ||
title: Momento Kotlin SDK | ||
pagination_prev: null | ||
sidebar_label: Kotlin | ||
description: Information about the Momento Kotlin SDK | ||
--- | ||
|
||
# Momento Kotlin SDK | ||
|
||
The Momento Kotlin SDK is available via Maven Central: [`software.momento.kotlin:sdk`](https://central.sonatype.com/artifact/software.momento.kotlin/sdk). | ||
|
||
The source code can be found on GitHub: [momentohq/client-sdk-kotlin](https://github.com/momentohq/client-sdk-kotlin). | ||
|
||
## Requirements | ||
|
||
- A Momento API key is required; you can get one from the [Momento Web Console](https://console.gomomento.com/). | ||
- At least the Java 11 run time installed or Android 23+ | ||
- mvn or gradle for downloading the sdk | ||
|
||
## Resources | ||
|
||
- [Kotlin SDK Examples](https://github.com/momentohq/client-sdk-kotlin/blob/main/examples/README.md): working example projects that illustrate how to use the Kotlin SDK | ||
- COMING SOON: Observability: Logging and Client-side Metrics with the Kotlin SDK | ||
- COMING SOON: Taking your code to prod: Configuration and Error handling in the Kotlin SDK | ||
|
||
## Integrations | ||
|
||
COMING SOON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...-snippets/src/examples/resolvers/source-parsers/languages/kotlin-snippet-source-parser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
RegexSnippetSourceParser, | ||
RegexSnippetTypeOptions, | ||
} from '../regex-snippet-source-parser'; | ||
import {ExampleSnippetType} from '../../../examples'; | ||
import * as path from 'path'; | ||
|
||
export class KotlinSnippetSourceParser extends RegexSnippetSourceParser { | ||
constructor(repoSourceDir: string) { | ||
const wholeFileExamplesDir = | ||
'examples/src/main/kotlin/software/momento/example/doc_examples'; | ||
const codeSnippetFiles: Array<string> = [ | ||
'examples/src/main/kotlin/software/momento/example/doc_examples/DocExamples.kt', | ||
]; | ||
super({ | ||
wholeFileExamplesDir: path.join(repoSourceDir, wholeFileExamplesDir), | ||
snippetTypeParseOptions: new Map< | ||
ExampleSnippetType, | ||
RegexSnippetTypeOptions | ||
>([ | ||
[ | ||
ExampleSnippetType.CODE, | ||
{ | ||
snippetSourceFiles: codeSnippetFiles.map(f => | ||
path.join(repoSourceDir, f) | ||
), | ||
startRegex: snippetId => | ||
new RegExp(`^suspend fun example_${snippetId.valueOf()}\\(`), | ||
endRegex: () => /^}/, | ||
numLeadingSpacesToStrip: 4, | ||
}, | ||
], | ||
]), | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you mean to change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did. That file moved in the dart sdk and broke the docs build. I forgot to comment.