Documentation ¶
Index ¶
- func AGW200(body string, headers map[string]string) events.APIGatewayV2HTTPResponse
- func AGW400() events.APIGatewayV2HTTPResponse
- func AGW404() events.APIGatewayV2HTTPResponse
- func AGW500() events.APIGatewayV2HTTPResponse
- func AffixIDsToString(levelTwoID, levelFourID, levelSevenID, levelTenID int) string
- func Atoi64(input string) (int64, error)
- func CanonicalLog(msg map[string]interface{})
- func Contains(slice []string, el string) bool
- func DownloadS3(ctx aws.Context, downloader *s3manager.Downloader, bucketName string, ...) error
- func DynamoDBGetItem(ctx aws.Context, svc *dynamodb.DynamoDB, input *dynamodb.GetItemInput) (*dynamodb.GetItemOutput, error)
- func DynamoDBPutItem(ctx aws.Context, svc *dynamodb.DynamoDB, ddbTableName *string, ...) (*dynamodb.PutItemOutput, error)
- func DynamoDBQuery(ctx aws.Context, svc *dynamodb.DynamoDB, input dynamodb.QueryInput) (*dynamodb.QueryOutput, error)
- func InitLogging()
- func KeysResponseToJson(result *dynamodb.QueryOutput, sorted, firstPage bool) (string, error)
- func KeysToJson(result *dynamodb.QueryOutput) (string, error)
- func MinSecToMilliseconds(input string) (int64, error)
- func PlayerDamageDoneToJson(result *dynamodb.GetItemOutput) (string, error)
- func PrettyStruct(input interface{}) (string, error)
- func RenameFileS3(ctx aws.Context, s3Svc *s3.S3, oldName, newName, bucketName string) error
- func SNSPublishMsg(ctx aws.Context, snsSvc *sns.SNS, input string, topicArn *string) error
- func SizeOfS3Object(ctx aws.Context, s3Svc *s3.S3, bucketName string, objectKey string) (int, error)
- func TimeMessageInQueue(e SQSEvent, i int) error
- func TimedAsPercent(dungeonID int, durationInMilliseconds float64) (durAsPercent float64, intime int, err error)
- func TimestreamQuery(ctx aws.Context, query *string, querySvc *timestreamquery.TimestreamQuery) (*timestreamquery.QueryOutput, error)
- func WriteToTimestream(ctx aws.Context, writeSvc *timestreamwrite.TimestreamWrite, ...) error
- type DamagePerSpell
- type DynamoDBKeys
- type DynamoDBPlayerDamageDone
- type DynamodbDedup
- type JSONKeys
- type JSONKeysResponse
- type PlayerDamage
- type PlayerDamageDone
- type S3Event
- type SQSEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AGW200 ¶
func AGW200(body string, headers map[string]string) events.APIGatewayV2HTTPResponse
AGW200 returns a agi gw v2 success response
func AGW400 ¶
func AGW400() events.APIGatewayV2HTTPResponse
AGW400 returns a error agi gw v2 response
func AGW404 ¶
func AGW404() events.APIGatewayV2HTTPResponse
AGW404 returns a error agi gw v2 response
func AGW500 ¶
func AGW500() events.APIGatewayV2HTTPResponse
AGW500 returns a error agi gw v2 response
func AffixIDsToString ¶
AffixIDsToString takes an array of affix ids and converts them to a readable list of array names separated by commas TODO:
- rethink if I actually need this, displaying a list of affixes as string takes a lot of space, should just return an array of ids and string and display icons and display the name on hover
func CanonicalLog ¶
func CanonicalLog(msg map[string]interface{})
CanonicalLog writes a structured message to stdout if the log level is atleast INFO
func DownloadS3 ¶
func DownloadS3(ctx aws.Context, downloader *s3manager.Downloader, bucketName string, objectKey string, fileContent io.WriterAt) error
DownloadS3 downloads a file from s3
func DynamoDBGetItem ¶
func DynamoDBGetItem(ctx aws.Context, svc *dynamodb.DynamoDB, input *dynamodb.GetItemInput) (*dynamodb.GetItemOutput, error)
DynamoDBGetItem gets a single item from dynamodb and always returns consumed capacity
func DynamoDBPutItem ¶
func DynamoDBPutItem(ctx aws.Context, svc *dynamodb.DynamoDB, ddbTableName *string, record interface{}) (*dynamodb.PutItemOutput, error)
DynamoDBPutItem writes a single item to dynamodb and always returns consumed capacity. just pass in a struct for record it will be converted to a ddb type, make sure the struct as the json tags that reflect the name in ddb, such as pk and sk
func DynamoDBQuery ¶
func DynamoDBQuery(ctx aws.Context, svc *dynamodb.DynamoDB, input dynamodb.QueryInput) (*dynamodb.QueryOutput, error)
DynamoDBQuery is a helper to simplify querying a dynamo db table
func InitLogging ¶
func InitLogging()
InitLogging sets up the logging for every lambda and should be called before the handler
func KeysResponseToJson ¶
func KeysResponseToJson(result *dynamodb.QueryOutput, sorted, firstPage bool) (string, error)
KeysResponseToJson takes a dynamodb query output and converts it to be consumed by the frontend mostly it makes sure the pagination works correctly this is used for top keys and top keys per dungeon
func KeysToJson ¶
func KeysToJson(result *dynamodb.QueryOutput) (string, error)
KeysToJson is unused right now, I think it was the predecessor of KeysResponseToJson
func MinSecToMilliseconds ¶
MinSecToMilliseconds converts time in the "minute:seconds" format to milliseconds
func PlayerDamageDoneToJson ¶
func PlayerDamageDoneToJson(result *dynamodb.GetItemOutput) (string, error)
PlayerDamageDoneToJson returns the log specific damage result, including damage per spell breakdown, both damage per player and per spell are sorted before saving to the db. We don't need an extra JSON struct, like for keys, because there is no pagination etc.
func PrettyStruct ¶
PrettyStruct converts a struct, slice of a struct or map into a readable string
func RenameFileS3 ¶
RenameFileS3 creates a copy of a file and deletes the old one, because you can't rename files =(
func SNSPublishMsg ¶
SNSPublishMsg publishes a message to an SNS topic
func SizeOfS3Object ¶
func SizeOfS3Object(ctx aws.Context, s3Svc *s3.S3, bucketName string, objectKey string) (int, error)
SizeOfS3Object checks the file size without actually downloading it in KB
func TimeMessageInQueue ¶
TimeMessageInQueue IMPROVE: only pass in pointer to SQSEvent we can see an overall trend of this in the SQS metrics, I created this to double check how fast messages are polled with fargate, but since I use lambda the lambda service takes care of this and messages are usually only 10ms old before they are pushed into lambda
func TimedAsPercent ¶
func TimedAsPercent(dungeonID int, durationInMilliseconds float64) (durAsPercent float64, intime int, err error)
TimedAsPercent determines if a key was intime, deplete, two chest or three chest and returns the quotient of the expected intime duration and the actual duration in milliseconds this is used to order the keys, so the fastest within a key level is first TODO: add table test and check 0 duration
func TimestreamQuery ¶
func TimestreamQuery(ctx aws.Context, query *string, querySvc *timestreamquery.TimestreamQuery) (*timestreamquery.QueryOutput, error)
TimestreamQuery runs a query against timestream and checks if the query is already finished. timestream returns a response after ~6 seconds even if it is not finished. It checks the NextToken and reruns the query if need be
func WriteToTimestream ¶
func WriteToTimestream(ctx aws.Context, writeSvc *timestreamwrite.TimestreamWrite, e *timestreamwrite.WriteRecordsInput) error
WriteToTimestream takes a slice of records to write and writes batches of 100 records to timestream
Types ¶
type DamagePerSpell ¶
type DamagePerSpell struct { SpellID int `json:"spell_id"` SpellName string `json:"spell_name"` Damage int64 `json:"damage"` }
DamagePerSpell is a part of PlayerDamageDone and contains the breakdown of damage per spell
type DynamoDBKeys ¶
type DynamoDBKeys struct { Pk string `json:"pk"` Sk string `json:"sk"` Damage []PlayerDamage `json:"player_damage"` Gsi1pk string `json:"gsi1pk"` Gsi1sk string `json:"gsi1sk"` Duration string `json:"duration"` Deaths int `json:"deaths"` Affixes string `json:"affixes"` Keylevel int `json:"keylevel"` DungeonName string `json:"dungeon_name"` DungeonID int `json:"dungeon_id"` CombatlogHash string `json:"combatlog_hash"` Finished bool `json:"finished"` Intime int `json:"intime"` Date int64 `json:"date"` CreatedAt string `json:"created_at"` }
DynamoDBKeys is used to display the top keys and top keys per dungeon
type DynamoDBPlayerDamageDone ¶
type DynamoDBPlayerDamageDone struct { Pk string `json:"pk"` Sk string `json:"sk"` Damage []PlayerDamageDone `json:"player_damage"` Duration string `json:"duration"` Deaths int `json:"deaths"` Affixes string `json:"affixes"` Keylevel int `json:"keylevel"` DungeonName string `json:"dungeon_name"` DungeonID int `json:"dungeon_id"` CombatlogHash string `json:"combatlog_hash"` Finished bool `json:"finished"` Intime int `json:"intime"` Date int64 `json:"date"` CreatedAt string `json:"created_at"` }
DynamoDBPlayerDamageDone is used to save player damage done to dynamodb, log specific view
type DynamodbDedup ¶
type DynamodbDedup struct { Pk string `json:"pk"` Sk string `json:"sk"` CreatedAt string `json:"created_at"` }
DynamodbDedup is used to save if a Combatlog has already been uploaded to timestream Pk: fmt.Sprintf("DEDUP#%d", hash), Sk: fmt.Sprintf("DEDUP#%d", hash),
type JSONKeys ¶
type JSONKeys struct { Damage []PlayerDamage `json:"player_damage"` Duration string `json:"duration"` Deaths int `json:"deaths"` Affixes string `json:"affixes"` Keylevel int `json:"keylevel"` DungeonName string `json:"dungeon_name"` DungeonID int `json:"dungeon_id"` CombatlogHash string `json:"combatlog_hash"` Intime int `json:"intime"` }
type JSONKeysResponse ¶
type PlayerDamage ¶
type PlayerDamage struct { Damage int `json:"damage"` // TODO: convert to int64 Name string `json:"player_name"` PlayerID string `json:"player_id"` Class string `json:"class"` Specc string `json:"specc"` }
PlayerDamage contains player and damage info for the top keys view etc.
type PlayerDamageDone ¶
type PlayerDamageDone struct { Damage int64 `json:"damage"` DamagePerSpell []DamagePerSpell `json:"damage_per_spell"` Name string `json:"player_name"` PlayerID string `json:"player_id"` Class string `json:"class"` Specc string `json:"specc"` }
PlayerDamageDone contains player and damage per spell info for the log specific view
type S3Event ¶
type S3Event struct { Records []struct { S3 struct { Bucket struct { Name string `json:"name"` } `json:"bucket"` Object struct { Key string `json:"key"` } `json:"object"` } `json:"s3"` } `json:"Records"` }
S3Event base structure for an s3 event, to unmarshal a json into it
type SQSEvent ¶
type SQSEvent struct { Records []struct { MessageID string `json:"messageId"` ReceiptHandle string `json:"receiptHandle"` Body string `json:"body"` Attributes struct { ApproximateReceiveCount string `json:"ApproximateReceiveCount"` SentTimestamp string `json:"SentTimestamp"` SenderID string `json:"SenderId"` ApproximateFirstReceiveTimestamp string `json:"ApproximateFirstReceiveTimestamp"` } `json:"attributes"` EventSource string `json:"eventSource"` EventSourceARN string `json:"eventSourceARN"` AwsRegion string `json:"awsRegion"` } `json:"Records"` }
SQSEvent is all the data that gets passed into the lambda from the q IMPROVE: use events.SQSEvent, see summary lambda