{"id":21674517,"url":"https://github.com/j2gg0s/kfile","last_synced_at":"2025-03-20T08:47:48.209Z","repository":{"id":57614159,"uuid":"373506844","full_name":"j2gg0s/kfile","owner":"j2gg0s","description":"use Kafka as Distribute File System, automatic support Append and Expire","archived":false,"fork":false,"pushed_at":"2021-06-28T11:04:15.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-25T09:44:41.439Z","etag":null,"topics":["append","distributefilesystem","expire","kafka"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/j2gg0s.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-03T12:54:32.000Z","updated_at":"2021-06-28T09:32:03.000Z","dependencies_parsed_at":"2022-09-10T08:23:12.184Z","dependency_job_id":null,"html_url":"https://github.com/j2gg0s/kfile","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j2gg0s%2Fkfile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j2gg0s%2Fkfile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j2gg0s%2Fkfile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j2gg0s%2Fkfile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/j2gg0s","download_url":"https://codeload.github.com/j2gg0s/kfile/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244583196,"owners_count":20476233,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["append","distributefilesystem","expire","kafka"],"created_at":"2024-11-25T13:48:00.596Z","updated_at":"2025-03-20T08:47:48.173Z","avatar_url":"https://github.com/j2gg0s.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kfile\n\nUse kafka for distribute file storage, support write append and auto expire.\n\n# User story\n\nIn our team, we use PostgreSQL/MySQL as data storage, Kafka as message queue.\nIt's difficult to share file between multi instances under these components.\n\nFor use, sharing file is a rare situation, only like export thoundes of records.\nWe don't want to import one Distributed File System, so we use kafka to save temporary file.\n\n# Usage\n\nWrite:\n\n```go\nname := \"fileA\"\nwriter, err := kfile.NewWriter(\n    topic, name,\n    client,\n    kfile.WithNumPartitions(int32(numPartitions)),\n    kfile.WithReplicationFactor(int16(replicationFactor)),\n    kfile.WithTopicRetention(time.Hour*24*31))\nif err != nil {\n    fmt.Println(fmt.Errorf(\"new file: %w\", err))\n    return\n}\nfor j := 0; j \u003c 100; j++ {\n    err := writer.Append(\n        kfile.Line([]byte(fmt.Sprintf(\"Line %d of file %s\\n\", j, name))))\n    if err != nil {\n        fmt.Println(fmt.Errorf(\"write: %w\", err))\n        return\n    }\n}\nuri, err := writer.Close(10 * time.Second)\nif err != nil {\n    fmt.Println(fmt.Errorf(\"close file: %w\", err))\n    return\n}\n\nfmt.Printf(\"write to %s\\n\", uri)\n```\n\nRead:\n\n```go.\nreader, err := kfile.NewReader(uri, client)\nif err != nil {\n    fmt.Println(fmt.Errorf(\"new reader: %w\", err))\n    return\n}\nbuf, err := reader.ReadAll(0)\nif err != nil {\n    fmt.Println(fmt.Errorf(\"read: %w\", err))\n    return\n}\nfmt.Printf(\"read from %s\\n\", uri)\nfmt.Println(buf.String())\nif _, err := reader.Close(0); err != nil {\n    fmt.Println(err)\n    return\n}\n```\n\nSee more in `example/`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj2gg0s%2Fkfile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj2gg0s%2Fkfile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj2gg0s%2Fkfile/lists"}